← Back to research
Guides14 min readPublished 2026-07-22

Kimi K3 API OpenAI Compatible Integration Guide (2026)

Use the kimi k3 api openai compatible pattern to call Moonshot K3 and LumeAPI GPT, Claude, or Gemini from one Python app, with routing and pricing guidance.

By LumeAPI Engineering Team

Multi-Model API hub →

Last verified: July 22, 2026

Short path: Start with the multi-model API guide, review the multi-model API options, then compare supported models on AI API pricing. Kimi K3 uses Moonshot's endpoint; it is not served through LumeAPI.

If you are searching for a kimi k3 api openai compatible integration, the important detail is that Kimi K3 and LumeAPI belong in the same application, but not behind the same base URL. Kimi K3 is called through Moonshot AI at https://api.moonshot.ai/v1 with the model id kimi-k3. GPT, Claude, and Gemini models below use LumeAPI at https://api.lumeapi.site/v1.

That split still gives you one practical application architecture: use two OpenAI-compatible clients, keep provider credentials separate, and route each task to an explicit model. Do not point kimi-k3 at LumeAPI. Kimi K3 is not in the LumeAPI catalog.

Quick Answer

QuestionDirect answer
How do I call Kimi K3 with the OpenAI Python SDK?Create an OpenAI client with base_url="https://api.moonshot.ai/v1" and call model="kimi-k3".
Can Kimi K3 and LumeAPI models share one app?Yes. Use a Moonshot client for K3 and a LumeAPI client for GPT, Claude, or Gemini.
What should I route to Kimi K3?Long-context analysis, difficult reasoning, and workflows where K3's 1M context is useful.
What should I route to LumeAPI?GPT, Claude, and Gemini tasks where you want LumeAPI's catalog rates and a common OpenAI-compatible gateway.
What is the main integration catch?OpenAI-compatible means the request shape is similar, not that model behavior, parameters, latency, or native features are identical.

In short

The cleanest kimi k3 api openai compatible design is a dual-client pattern: Moonshot for kimi-k3, LumeAPI for the catalog models it actually supports. Keep routing explicit because base URLs, billing, model ids, and provider-specific behavior differ. Kimi K3 is a strong candidate for long-context and reasoning-heavy work, while LumeAPI gives you one endpoint for selected GPT, Claude, and Gemini models. For model comparisons, see Kimi K3 vs GPT-5.6 Sol, vs Claude Sonnet, and vs Gemini 3.1 Pro.

What most guides get wrong

The common myth is that an OpenAI-compatible model can be moved between gateways by changing only the model string. That is how teams end up debugging a 404 that looks like an authentication problem.

Compatibility usually means the provider accepts familiar request paths such as /chat/completions, Bearer authentication, messages, temperature, and a model field. It does not mean every provider has the same catalog or supports the same extensions. The model id kimi-k3 is valid at Moonshot's https://api.moonshot.ai/v1; it is not a valid LumeAPI model id. Conversely, a LumeAPI model such as claude-sonnet-4-6 must be sent to https://api.lumeapi.site/v1.

The second mistake is assuming that one SDK client must mean one provider. The Python SDK client is cheap to instantiate. Your application can hold two clients and select one through a small routing function. That separation is clearer than hiding provider-specific credentials and URLs in a single mutable global client. If you need a broader multi-provider checklist, use the multi-model production checklist and OpenAI-compatible Python patterns.

A realistic production scenario

Consider Priya's eight-person platform team. Their Python service uses FastAPI, the OpenAI Python SDK, Redis for job state, and a queue for document analysis. The original implementation sends every request to OpenAI directly. A new workflow needs to inspect very large repositories and compare changes across many files, so the team wants Kimi K3's 1M context window. They also want Claude for carefully written incident summaries and GPT for short structured extraction.

The first attempt changes model="gpt-5.5" to model="kimi-k3" but leaves base_url pointing at api.openai.com. The request fails before inference. The second attempt points the shared client at Moonshot, which makes the K3 call work but breaks the existing GPT and Claude routes.

The fix is two clients with two environment variables. A router chooses kimi-k3 for repository-scale analysis, claude-sonnet-4-6 for narrative synthesis, and gpt-5.4-mini for low-cost classification. Each request logs provider, model, input tokens, output tokens, latency, and retry count. That last part matters: a multi-model system is difficult to operate if the invoice and application logs cannot be joined.

Expert take

Kimi K3 is best understood as a separate high-capability route, not as another interchangeable entry in the LumeAPI catalog. Moonshot describes K3 as its flagship model, with a 2.8T-class architecture and a 1M context window. Those capabilities change the routing question. You may choose K3 because the task requires more context or deeper reasoning, not because the Python call looks like an OpenAI call.

Use reasoning_effort deliberately. The supported values for this integration are low, high, and max. A low setting can make sense for straightforward transformation or extraction. High or max is more appropriate for difficult analysis, but it can increase completion length and therefore cost. Do not place reasoning_effort="max" in a shared default used by every queue.

The boundary is equally important. This advice does not apply when a workflow depends on a provider-native feature that is absent or behaves differently through an OpenAI-compatible endpoint. Batch processing, prompt caching, tool semantics, structured output guarantees, streaming details, and safety controls need provider-specific verification. LumeAPI is an independent third-party gateway, not OpenAI, Anthropic, or Google, and it does not promise identical behavior to every native API feature. Kimi K3 is not routed through LumeAPI at all.

A good router therefore decides at the application boundary. It does not silently retry a failed K3 request against Claude, because a different model may produce a different answer and a different bill. If you need fallback, define it as a documented policy with idempotency keys or job-level deduplication. Otherwise, a timeout can create two completed generations and charge you twice.

What launch benchmarks imply for routing (July 2026)

You do not need to read every leaderboard to configure kimi-k3 vs LumeAPI catalog models — but you should know why Moonshot positions K3 as a separate route. The Kimi K3 technical blog (July 16, 2026) reports:

Workload signalKimi K3 vs GPT-5.6 Sol (Moonshot table)Integration takeaway
Terminal / CLI agentsTerminal-Bench 2.1: 88.3 vs 88.8Tie; harness-dependent
Long-horizon SWEFrontierSWE: 81.2 vs 71.3Prefer K3 route for repo-scale plans
Bug-fix benchDeepSWE: 67.5 vs 73.0Prefer LumeAPI Sol/Terra for focused fixes
Document OCR / layoutOmniDocBench: 91.1 (K3 leads Fable 5 / GPT-5.6 in blog)Prefer K3 for scanned PDFs and visual docs

Kimi Code shipped alongside K3 as Moonshot's terminal agent product. If you call only the raw API with the OpenAI Python SDK, you are not automatically getting KimiCode's harness — benchmark scores may overstate what a minimal chat.completions integration delivers.

Our rule for dual-client apps: map benchmarks to route triggers, not global defaults.

  • moonshot + kimi-k3 → repository map, visual document batch, cross-file migration plan.
  • lumeapi + gpt-5.6-terra / gpt-5.4-mini → classification, short extraction, routine edits.
  • lumeapi + gpt-5.6-sol or claude-sonnet-4-6 → patch application, test repair, user-facing summaries.

Re-check K3 API pricing when enabling reasoning_effort="max" on high-volume queues — reasoning tokens count as output.

How the two-provider setup works

There are four values to keep separate:

  1. The provider credential.
  2. The provider base URL.
  3. The provider model id.
  4. The provider-specific options.

For Kimi K3, use:

text
MOONSHOT_API_KEY
https://api.moonshot.ai/v1
kimi-k3

For LumeAPI, use:

text
LUMEAPI_KEY
https://api.lumeapi.site/v1
one of the catalog model ids

The request path is familiar in both cases:

text
POST /chat/completions
Authorization: Bearer <provider-key>

The familiar path is useful because existing OpenAI client code needs only a small adapter. It is not a reason to share credentials or treat all responses as behaviorally identical.

Before writing application code, check the Kimi platform documentation and K3 pricing for current parameter support, rate limits, and billing. Moonshot's published K3 rates should also be rechecked before deployment because provider pricing can change.

Install the Python client

Install the OpenAI-compatible Python SDK:

bash
pip install openai

Set both credentials in the process environment:

bash
export MOONSHOT_API_KEY="your-moonshot-key"
export LUMEAPI_KEY="your-lumeapi-key"

Do not put either key in source code, a notebook committed to Git, or a client-side application. The application server should own the keys. If separate teams operate the providers, give each credential only the permissions and wallet access required for its route.

Minimal Kimi K3 call with Python

This is the smallest useful kimi k3 api python example. The Moonshot base URL is explicit, and the model id is the Moonshot id, kimi-k3.

python
import os
from openai import OpenAI

moonshot = OpenAI(
    api_key=os.environ["MOONSHOT_API_KEY"],
    base_url="https://api.moonshot.ai/v1",
)

response = moonshot.chat.completions.create(
    model="kimi-k3",
    reasoning_effort="high",
    messages=[
        {
            "role": "system",
            "content": "You are a careful code reviewer. Cite the file and explain the failure mode.",
        },
        {
            "role": "user",
            "content": "Review this function for retry, timeout, and idempotency risks:\n\n"
                       "def process(job):\n"
                       "    return call_remote_service(job)",
        },
    ],
)

print(response.choices[0].message.content)

The reasoning_effort setting is part of the K3 route. Use low, high, or max; start with high only for tasks that need it. For routine classification, a lower setting or a smaller catalog model may be a better operational choice.

The equivalent environment-driven version is useful when deployment configuration changes between staging and production:

python
from openai import OpenAI
import os

moonshot = OpenAI(
    api_key=os.environ["MOONSHOT_API_KEY"],
    base_url=os.getenv("MOONSHOT_BASE_URL", "https://api.moonshot.ai/v1"),
)

result = moonshot.chat.completions.create(
    model=os.getenv("MOONSHOT_MODEL", "kimi-k3"),
    reasoning_effort="low",
    messages=[
        {"role": "user", "content": "Extract the incident severity and affected service."}
    ],
)

print(result.choices[0].message.content)

That MOONSHOT_BASE_URL value is the Moonshot API base URL for this integration. Do not substitute the LumeAPI URL just because both endpoints accept OpenAI-style requests.

Add LumeAPI models beside Kimi K3

Create a second client rather than mutating the first one:

python
import os
from openai import OpenAI

moonshot = OpenAI(
    api_key=os.environ["MOONSHOT_API_KEY"],
    base_url="https://api.moonshot.ai/v1",
)

lumeapi = OpenAI(
    api_key=os.environ["LUMEAPI_KEY"],
    base_url="https://api.lumeapi.site/v1",
)

def complete(provider: str, model: str, messages: list[dict], **kwargs):
    if provider == "moonshot":
        return moonshot.chat.completions.create(
            model=model,
            messages=messages,
            **kwargs,
        )

    if provider == "lumeapi":
        return lumeapi.chat.completions.create(
            model=model,
            messages=messages,
            **kwargs,
        )

    raise ValueError(f"Unsupported provider: {provider}")

kimi_result = complete(
    "moonshot",
    "kimi-k3",
    [{"role": "user", "content": "Analyze these repository changes for regressions."}],
    reasoning_effort="high",
)

claude_result = complete(
    "lumeapi",
    "claude-sonnet-4-6",
    [{"role": "user", "content": "Turn this analysis into a concise incident summary."}],
)

print(kimi_result.choices[0].message.content)
print(claude_result.choices[0].message.content)

This is the practical multi model kimi gpt claude one client pattern, with one correction: the application has one integration layer, but it should retain separate provider clients underneath. That gives you a common calling convention without pretending the providers are one service.

A route table makes the policy visible:

python
ROUTES = {
    "repository_analysis": ("moonshot", "kimi-k3"),
    "incident_summary": ("lumeapi", "claude-sonnet-4-6"),
    "short_classification": ("lumeapi", "gpt-5.4-mini"),
    "general_reasoning": ("lumeapi", "gpt-5.6-terra"),
}

def run_task(task_type: str, messages: list[dict]):
    try:
        provider, model = ROUTES[task_type]
    except KeyError as exc:
        raise ValueError(f"No route configured for {task_type}") from exc

    kwargs = {}
    if provider == "moonshot":
        kwargs["reasoning_effort"] = "high"

    return complete(provider, model, messages, **kwargs)

Keep this mapping in configuration or a versioned policy module. A hidden route selected by prompt wording is harder to test and can produce unexpected provider charges.

Choosing Kimi K3, GPT, Claude, or Gemini

The decision should follow workload characteristics rather than brand preference.

WorkloadRecommended routeWhy
Very large repository or document contextMoonshot kimi-k3Kimi K3 is documented here as a 1M-context model.
Reasoning-heavy analysis with Moonshot-specific controlsMoonshot kimi-k3Supports reasoning_effort=low, high, or max.
General reasoning through the LumeAPI endpointLumeAPI gpt-5.6-terraLower catalog rate than gpt-5.6-sol in the supplied pricing.
High-end GPT capability through LumeAPILumeAPI gpt-5.6-solUse when your evaluations justify the higher output rate.
Careful prose or synthesisLumeAPI claude-sonnet-4-6A mid-tier Claude route in the supplied catalog.
Low-cost short classificationLumeAPI gpt-5.4-miniThe lowest supplied GPT input and output rates.
Gemini-specific application testingLumeAPI gemini-3-flash or gemini-3.5-flashUse the exact catalog id and validate response behavior.

This is a routing matrix, not a benchmark. The supplied facts do not establish comparative latency, quality scores, or feature parity. Measure your own prompts with a fixed evaluation set before changing a production default.

Capability, routing, latency, and context

Kimi K3's context capacity is the clearest reason to route a task to Moonshot. A large context can remove an application-side retrieval or summarization stage, but sending a large context on every request is still expensive. Context size is not a free optimization.

Latency should be measured separately for time to first token and total completion time. A reasoning-heavy request may have a different latency profile from a short extraction request even on the same model. Record provider and model labels with each timing measurement. Comparing only “API latency” while mixing K3 reasoning settings and GPT short answers produces a useless average.

Routing is safer when each route has a contract:

text
repository_analysis:
  provider: moonshot
  model: kimi-k3
  reasoning_effort: high
  max_input_tokens: application-defined

incident_summary:
  provider: lumeapi
  model: claude-sonnet-4-6

classification:
  provider: lumeapi
  model: gpt-5.4-mini

The contract should also state whether streaming, tools, JSON output, or multimodal inputs are required. If a task depends on one of those features, verify it against the selected endpoint instead of assuming OpenAI compatibility covers it.

Pricing and monthly token math

Moonshot's published Kimi K3 rates supplied for this article are approximately:

  • Cache-hit input: $0.30 per 1M tokens
  • Cache-miss input: $3.00 per 1M tokens
  • Output: $15.00 per 1M tokens

These are approximate reference figures and should be verified against Moonshot's current pricing before launch. They are not LumeAPI catalog rates. The LumeAPI catalog was updated July 22, 2026, and lists the following official reference rates and LumeAPI rates per 1M input and output tokens:

ModelOfficial input / outputLumeAPI input / outputCatalog discount
gpt-5.6-sol$5.00 / $30.00$1.50 / $9.0070%
gpt-5.6-terra$2.50 / $15.00$0.75 / $4.5070%
gpt-5.5$5.00 / $30.00$1.50 / $9.0070%
gpt-5.4$2.50 / $15.00$0.75 / $4.5070%
gpt-5.4-mini$0.75 / $4.50$0.225 / $1.3570%
claude-opus-4-8$5.00 / $25.00$2.50 / $12.5050%
claude-opus-4-7$5.00 / $25.00$2.50 / $12.5050%
claude-sonnet-4-6$3.00 / $15.00$1.50 / $7.5050%
claude-fable-5$10.00 / $50.00$5.00 / $25.0050%
gemini-3.1-pro-preview$2.00 / $12.00$1.00 / $6.0050%
gemini-3.5-flash$1.50 / $9.00$0.75 / $4.5050%
gemini-3-flash$0.50 / $3.00$0.25 / $1.5050%

For a concrete comparison, assume a month with 10M input tokens and 1M output tokens, before taxes, wallet adjustments, or any other provider charges:

RouteMonthly calculationEstimated monthly token cost
Kimi K3, cache miss10 × $3.00 + 1 × $15.00$45.00
Kimi K3, cache hit10 × $0.30 + 1 × $15.00$18.00
LumeAPI gpt-5.6-terra10 × $0.75 + 1 × $4.50$12.00
LumeAPI claude-sonnet-4-610 × $1.50 + 1 × $7.50$22.50
LumeAPI gpt-5.4-mini10 × $0.225 + 1 × $1.35$3.60

The Kimi calculation demonstrates why cache status matters, while the LumeAPI calculations show why a single high-capability model should not handle every small task. These numbers do not prove which model is cheaper for your workload. Output volume, cache eligibility, retries, context construction, and quality-driven rework can dominate the simple token multiplication.

The LumeAPI gateway uses USD wallet billing and transparent per-token catalog rates. Kimi K3 billing remains associated with Moonshot because the request goes to Moonshot. Keep those ledgers separate.

Add retries without duplicating expensive work

A retry wrapper should distinguish transient transport errors from invalid requests. Retrying a wrong base URL, an unknown model id, or an invalid parameter only repeats failure. Retrying a timeout can also duplicate a successful generation if the server completed the request but the client lost the response.

Use bounded retries and log a request identifier from your own application:

python
import random
import time
from openai import APIConnectionError, APITimeoutError, RateLimitError

RETRYABLE = (APIConnectionError, APITimeoutError, RateLimitError)

def call_with_backoff(client, *, model, messages, request_id, **kwargs):
    for attempt in range(3):
        try:
            return client.chat.completions.create(
                model=model,
                messages=messages,
                timeout=60.0,
                **kwargs,
            )
        except RETRYABLE:
            if attempt == 2:
                raise

            delay = (2 ** attempt) + random.uniform(0, 0.25)
            time.sleep(delay)

    raise RuntimeError(f"Unreachable retry state for {request_id}")

The request_id is not sent to the provider in this snippet; it is the correlation value your logs should carry. For jobs with side effects, persist the job state before retrying and make downstream actions idempotent. Do not silently switch from Kimi K3 to a LumeAPI model after a timeout unless the task contract explicitly permits a different answer.

Operational checklist

Before deploying the integration, verify each item:

  1. MOONSHOT_API_KEY is used only with https://api.moonshot.ai/v1.
  2. LUMEAPI_KEY is used only with https://api.lumeapi.site/v1.
  3. Kimi requests use model="kimi-k3".
  4. LumeAPI requests use an exact supplied catalog id.
  5. No code path sends kimi-k3 to LumeAPI.
  6. reasoning_effort is set only on routes that support and need it.
  7. Input and output tokens are recorded by provider and model.
  8. Retry counts, timeout counts, and rate-limit responses are recorded.
  9. A timeout cannot trigger a duplicate side effect.
  10. Prompt, tool, streaming, and structured-output behavior is tested for each route.
  11. Moonshot pricing is checked against the current provider documentation.
  12. LumeAPI and Moonshot costs are reconciled as separate billing sources.

A small route-level test catches the most expensive configuration error:

python
def test_route_configuration():
    provider, model = ROUTES["repository_analysis"]
    assert provider == "moonshot"
    assert model == "kimi-k3"

    provider, model = ROUTES["general_reasoning"]
    assert provider == "lumeapi"
    assert model == "gpt-5.6-terra"

Add a request-shape test with mocked clients as well. It should assert that the Moonshot client receives reasoning_effort and the LumeAPI client does not receive K3's model id.

FAQ

How do I use the kimi k3 api openai compatible interface in Python?

Use the OpenAI Python SDK with base_url="https://api.moonshot.ai/v1" and model="kimi-k3". Authenticate with MOONSHOT_API_KEY, then call chat.completions.create().

What is the Moonshot API base URL for Kimi K3?

The Moonshot API base URL is https://api.moonshot.ai/v1. Kimi K3 is not available at the LumeAPI base URL.

Is Kimi K3 available through LumeAPI?

No, Kimi K3 is not in the LumeAPI catalog. Send kimi-k3 to Moonshot, and send supported GPT, Claude, or Gemini catalog ids to https://api.lumeapi.site/v1.

Which kimi k3 reasoning effort should I use?

Start with low for simple extraction, use high for difficult analysis, and reserve max for tasks where extra reasoning has passed your quality evaluation. Higher reasoning can increase output tokens and cost.

Can one Python application use Kimi K3, GPT, and Claude?

Yes. Instantiate a Moonshot client and a LumeAPI client, then select the provider and exact model through a route table. This keeps credentials and billing boundaries clear while preserving one application-level interface.

Does OpenAI compatibility guarantee identical model behavior?

No. It mostly standardizes request and response shapes. Context handling, reasoning controls, tool calls, structured output, streaming, latency, errors, and native features still require provider-specific tests.

Next steps

  1. Add the two clients to a small integration module and run one known prompt against kimi-k3, gpt-5.6-terra, and claude-sonnet-4-6.
  2. Build a fixed evaluation set for context-heavy analysis, short classification, and narrative synthesis; record quality, latency, token counts, and retry behavior.
  3. Move the route policy into production configuration and review the LumeAPI multi-model API offering for the GPT, Claude, and Gemini routes that belong behind the gateway.