Documentation Index
Fetch the complete documentation index at: https://docs.kymaapi.com/llms.txt
Use this file to discover all available pages before exploring further.
Install
pip install langchain-openai
Setup
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
base_url="https://kymaapi.com/v1",
api_key="ky-your-api-key",
model="qwen-3.6-plus",
)
Basic Usage
response = llm.invoke("Explain RAG in simple terms")
print(response.content)
Streaming
for chunk in llm.stream("Write a short story"):
print(chunk.content, end="", flush=True)
With Prompt Template
from langchain_core.prompts import ChatPromptTemplate
prompt = ChatPromptTemplate.from_messages([
("system", "You are a {role}."),
("user", "{question}")
])
chain = prompt | llm
response = chain.invoke({
"role": "Python expert",
"question": "How do decorators work?"
})
print(response.content)
from langchain_core.tools import tool
@tool
def get_weather(city: str) -> str:
"""Get weather for a city."""
return f"Sunny, 72°F in {city}"
llm_with_tools = llm.bind_tools([get_weather])
response = llm_with_tools.invoke("What's the weather in Tokyo?")
print(response.tool_calls)
RAG Example
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
llm = ChatOpenAI(
base_url="https://kymaapi.com/v1",
api_key="ky-your-api-key",
model="gemini-2.5-flash", # 1M context for large documents
)
prompt = ChatPromptTemplate.from_messages([
("system", "Answer based on the following context:\n\n{context}"),
("user", "{question}")
])
chain = prompt | llm
response = chain.invoke({
"context": "Your retrieved documents here...",
"question": "What is the main topic?"
})
Recommended Models
| Use Case | Model | Why |
|---|
| General chains | qwen-3.6-plus | Best overall quality |
| RAG / long docs | gemini-2.5-flash | 1M context window |
| Tool calling | kimi-k2.6 | Best function calling |
| Fast responses | qwen-3-32b | Ultra-fast inference |
Kyma’s API is OpenAI-compatible, so langchain-openai / @langchain/openai work directly. No special package needed.