Kimi API Integration for Python
Call Moonshot AI’s Kimi models from Python through the adapter’s integration with the global Chat Completions API.
Installation
Use Python 3.10–3.14 and run this command in your virtual environment.
python -m pip install llm-api-adapter==0.11.0 llm-api-adapter-kimi==0.1.3Authentication
Open Kimi API key guide. Sign in to the Kimi API Platform and create a key for the global API. Set the following in the terminal where you will run the example.
export KIMI_API_KEY="your-api-key"Quickstart
Send a message
Save the example as chat.py and run python chat.py.
import os
from llm_api_adapter.models.messages.chat_message import UserMessage
from llm_api_adapter.universal_adapter import UniversalLLMAPIAdapter
adapter = UniversalLLMAPIAdapter(
organization="kimi",
model="kimi-k3",
api_key=os.environ["KIMI_API_KEY"],
)
response = adapter.chat(
messages=[UserMessage("Explain what an API is in one sentence.")],
max_tokens=1024,
timeout_s=60,
)
print(response.content)Supported models
Registry snapshot
llm-api-adapter-kimi==0.1.3
Prices are first-tier base rates from the adapter registry. Open a model for all tiers, cache rates, pricing schedules, and capability notes. Unknown means the registry has no value.
kimi-k3
- Context tokens
- 1,048,576
- Base input per million tokens
- 3 USD
- Maximum output tokens
- 1,048,576
- Base output per million tokens
- 15 USD
- Reasoning
- Supported
- Image URLs
- Unsupported
- PDF URLs
- Unsupported
- PDF bytes
- Unsupported
- JSON Schema output
- Unknown
- Pydantic output
- Unknown
kimi-k3.1-pro
- Context tokens
- 1,048,576
- Base input per million tokens
- 2 USD
- Maximum output tokens
- 1,048,576
- Base output per million tokens
- 10 USD
- Reasoning
- Supported
- Image URLs
- Unsupported
- PDF URLs
- Unsupported
- PDF bytes
- Unsupported
- JSON Schema output
- Unknown
- Pydantic output
- Unknown
kimi-k3.1-pro-highspeed
- Context tokens
- 1,048,576
- Base input per million tokens
- 4 USD
- Maximum output tokens
- 1,048,576
- Base output per million tokens
- 20 USD
- Reasoning
- Supported
- Image URLs
- Unsupported
- PDF URLs
- Unsupported
- PDF bytes
- Unsupported
- JSON Schema output
- Unknown
- Pydantic output
- Unknown
kimi-k2.6
- Context tokens
- 262,144
- Base input per million tokens
- 0.95 USD
- Maximum output tokens
- 32,768
- Base output per million tokens
- 4 USD
- Reasoning
- Supported
- Image URLs
- Unsupported
- PDF URLs
- Unsupported
- PDF bytes
- Unsupported
- JSON Schema output
- Unknown
- Pydantic output
- Unknown
Provider-specific features and limitations
- Send the full message history on every turn, including tool calls and results.
- Use inline image bytes or data URLs for image inputs. Omit parallel_tool_calls and avoid selecting a tool by name, which the integration rejects before sending a request.