Skip to main content

llm-api-adapter-kimi

An optional Kimi / Moonshot organization package for LLM API Adapter, a Python SDK with one shared interface for calling LLM APIs.

Calls Kimi / Moonshot through POST /v1/chat/completions without a provider SDK.

Installation

Install through the Core package extra:

pip install "llm-api-adapter[kimi]"

Direct installation is also supported when Core is managed separately:

pip install llm-api-adapter-kimi

Async requests need HTTPX:

pip install "llm-api-adapter[kimi,async]"

Synchronous requests remains the default. To opt into HTTPX for sync chat() and stream_chat(), install "llm-api-adapter[kimi,httpx]" and pass transport="httpx".

Quick start

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 retrieval-augmented generation.")],
    max_tokens=128,
)
print(response.content)

Supported models

  • kimi-k3
  • kimi-k3.1-pro
  • kimi-k3.1-pro-highspeed
  • kimi-k2.6

Capabilities

Capability Supported models
Text chat; sync/async streaming; application tools; portable JSON Schema/Pydantic output; image bytes and data URIs All models
Public ImagePart URLs and every DocumentPart PDF URL or byte Unsupported; rejected before HTTP

reasoning_level is resolved automatically from registry metadata. K3 and K3.1 Pro cannot disable reasoning, so reasoning_level="none" uses the registered minimum and warns. K2.6 maps "none" to disabled thinking and every other valid level to enabled thinking. When omitted, no thinking control is sent and Kimi's native default is preserved. Reasoning is never mixed into visible text; use capture_reasoning=True for opt-in observability.

All models reject named tool choice before transport. kimi-k3 and the K3.1 Pro models accept tool_choice="any"; kimi-k2.6 rejects it and accepts only automatic or disabled tool choice. Exact supported values, request rules, and exceptions are recorded in the Kimi registry.

History and files

Kimi Chat Completions is stateless: previous_response is accepted for the shared API but is not serialized. Send the complete messages history on each turn, including assistant tool calls and ToolMessage results.

Image bytes are encoded as data URIs. Public image URLs and every DocumentPart are rejected before transport. Kimi's Files API provides extracted text rather than a Chat Completions attachment, so the adapter does not upload, retain, download, extract, or delete caller files.

Kimi maps authentication/authorization (401/403), rate-limit (429), timeout (408/504), documented token/quota, and server failures to the matching public LLMAPI*Error; other client or SSE failures become LLMAPIClientError.

Automatic cache usage and pricing

usage.prompt_tokens_details.cached_tokens becomes Usage.cached_tokens; the legacy usage.cached_tokens field is also accepted. K3 and K3.1 Pro additionally report prompt_tokens_details.cache_write_tokens as Usage.cache_write_tokens for their automatic cache-write component. Both are disjoint subsets of total Usage.input_tokens. K2.6 has registered automatic cache-read pricing only.

Input cost uses ordinary, read, and applicable write rates from the USD registry tier without double counting. If a required read or write count is omitted, cost_input and cost_total stay None; known output cost can still be exposed. An explicitly reported zero stays zero. The adapter does not enable opt-in cache modes or account for selectable TTLs or storage charges. See the shared usage and pricing guide.

See the main llm-api-adapter README for the shared API contract, error mapping, and E2E/release documentation.

Metadata

Release files for llm-api-adapter-kimi 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-api-adapter-kimi 0.1.2
File Size Uploaded Provenance Actions
llm_api_adapter_kimi-0.1.2.tar.gz 26.2 kB Without provenance Details for llm_api_adapter_kimi-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llm-api-adapter-kimi 0.1.2
File Interpreter ABI Platform Actions
llm_api_adapter_kimi-0.1.2-py3-none-any.whl Python 3 none any Details for llm_api_adapter_kimi-0.1.2-py3-none-any.whl

Total release size: 44.3 kB

Release files / llm_api_adapter_kimi-0.1.2.tar.gz

Download URL llm_api_adapter_kimi-0.1.2.tar.gz
Size 26.2 kB
Tags Source
SHA-256 checksum
How to use checksums
97763a70df999ba627f05cb463bb02a88af7633e9c8cad2e849405b2bcf27a1b
BLAKE2b-256 checksum
How to use checksums
1f7c4ab0a587082623f91d30912a37b6109a0954005d4e33773a5945ecbc57b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / llm_api_adapter_kimi-0.1.2-py3-none-any.whl

Download URL llm_api_adapter_kimi-0.1.2-py3-none-any.whl
Size 18.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b3765f2a84b362b9e2c308156df6fa29e94bf52d65cbf4c60030c4ec88ee5c6
BLAKE2b-256 checksum
How to use checksums
7926a1614cbb041e5275ce754e87ffa31d8d2209a99b8614be5d001a999af606
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for llm-api-adapter-kimi 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page