{ "id": "chatcmpl-6adb0d430e590c70159c6ca1", "object": "chat.completion", "created": 1792740680, "model": "kimi-k3.1-pro", "choices": [ { "index": 0, "message": { "content": "1 + 1 = 2", "role": "assistant", "reasoning_content": "The user is asking a very simple math question: \"What is 1+1?\"\n\nThis is as basic as it gets. The answer is 2. There's no need for any elaborate explanation, headers, bullet points, or lengthy response. A simple, direct answer is appropriate here.\n\nI could just say \"2\" or \"1+1 = 2\" — keeping it brief and conversational since this is a casual chat context." }, "finish_reason": "stop" } ], "usage": { "completion_tokens": 112, "prompt_tokens": 373, "total_tokens": 485, "completion_tokens_details": { "reasoning_tokens": 90 }, "prompt_tokens_details": { "cache_write_tokens": 256 } }}
Set stream=true and stream_options.include_usage=true. Reasoning arrives in reasoning_content, followed by the answer in content. The final usage chunk has choices: [] and reports totals in the top-level usage.
The model name in the response example will be returned based on the model parameter in the request. When using the kimi-k3.1-pro model, the "model" field in the response will show "kimi-k3.1-pro".
Context Caching (Cache Write)
Cache Write is supported by kimi-k3.1-pro, kimi-k3.1-pro-highspeed, and kimi-k3. The Kimi API automatically enables context caching for repeated request prefixes; cached portions are billed at a lower price and respond faster. Use prompt_cache_options to control cache write behavior:
Parameter
Type
Description
prompt_cache_options
object
Context cache write options. When omitted, cache write is enabled by default (5m tier)
prompt_cache_options.mode
"implicit"
Cache write mode. Only implicit is supported: automatically writes the request prefix to the cache
prompt_cache_options.ttl
"5m" | "1h"
Lifetime of the written cache. Only 5m and 1h are supported (default 5m); the two tiers are independent
The cache is isolated per organization (org); caches are never shared across organizations.
When a request with the same prefix hits the cache within its lifetime, the cache entry is refreshed with its original TTL. Cache hits are billed only at the cache read price, with no additional cache write charge.
Cache writes are billed by TTL; see Pricing for details.
Manual cache clearing is not supported; cached prefixes expire automatically after at least 5 minutes of inactivity.
Explicit cache breakpoints are not supported: the request is rejected (HTTP 400) if prompt_cache_breakpoint appears in content.
Usage fieldsusage.prompt_tokens is always the total number of input tokens. Its internal breakdown is returned in prompt_tokens_details:
Field
Description
usage.prompt_tokens_details.cached_tokens
Tokens served from the cache (cache read)
usage.prompt_tokens_details.cache_write_tokens
Tokens written to the cache by this request (cache write)
cached_tokens, cache_write_tokens, and the uncached remainder are mutually exclusive and sum to prompt_tokens; the uncached remainder = prompt_tokens − cached_tokens − cache_write_tokens.In the non-streaming response above, the input is 373 tokens, including 256 cache-write tokens; output is 112 tokens, for a total of 373 + 112 = 485 tokens. Cache reads and writes are already included in prompt_tokens; output includes both reasoning and answer tokens. Do not count these tokens twice.For streaming requests, the full cache read/write breakdown is only returned in the usage field of the final chunk (set stream_options.include_usage=true). The Chat Completions response does not echo the applied mode/ttl (unlike the Responses API); keep track of the values used at request time.
The Kimi API is stateless and does not retain conversation history. To implement multi-turn dialogue, append the previous assistant reply (and any tool results, if applicable) back into the messages array before sending the next request.
messages = [ {"role": "system", "content": "You are Kimi."}, {"role": "user", "content": "Hello, my name is Li Lei."}]completion = client.chat.completions.create(model="kimi-k3.1-pro", messages=messages)reply = completion.choices[0].message# Preserve the full assistant reply, including reasoning_content and any tool_callsmessages.append(reply.model_dump(exclude_none=True))messages.append({"role": "user", "content": "What is 1+1?"})completion = client.chat.completions.create(model="kimi-k3.1-pro", messages=messages)print(completion.choices[0].message.content)
When the conversation history grows too long, retain only the most recent messages or compress earlier turns to avoid exceeding the model’s context limit.
Use the response_format parameter to constrain the model output format:
{"type": "text"} (default): plain text output
{"type": "json_object"}: forces a valid JSON Object output
{"type": "json_schema", "json_schema": {...}}: outputs structured data according to the given JSON Schema (Structured Output)
When using json_object, you must explicitly describe the expected JSON fields and types in the system prompt or user prompt, otherwise the model may produce unexpected results.
{ "model": "kimi-k3.1-pro", "messages": [ {"role": "system", "content": "Please output JSON containing title, author, and summary fields."}, {"role": "user", "content": "Summarize this article: Recursion solves problems by breaking them into smaller instances of the same problem, with a base case that ends the calls."} ], "response_format": {"type": "json_object"}}
Pass external tools defined as JSON Schema via the tools parameter. The model can decide to invoke them when appropriate.Request example
{ "model": "kimi-k3.1-pro", "messages": [{"role": "user", "content": "What is the weather in Beijing today?"}], "tools": [ { "type": "function", "function": { "name": "get_weather", "description": "Get the weather for a given city", "parameters": { "type": "object", "properties": { "city": {"type": "string", "description": "City name"} }, "required": ["city"] } } } ]}
tool_calls in the responseWhen finish_reason is "tool_calls", the model returns a tool_calls array containing id, function.name, and function.arguments:
{ "choices": [{ "message": { "role": "assistant", "content": "", "reasoning_content": "The user is asking about the weather in Beijing today. I have a tool available called `get_weather` that can get the weather for a given city. Let me use it to find the weather in Beijing.", "tool_calls": [ { "id": "get_weather_0_4d9e2559", "type": "function", "function": { "arguments": "{\"city\":\"Beijing\"}", "name": "get_weather" } } ] }, "finish_reason": "tool_calls" }]}
Submitting tool execution resultsAfter executing the tool locally, first append the complete assistant message from the response (including reasoning_content and tool_calls) unchanged to the original request’s messages, then append the tool result below. The tool_call_id must match the tool-call id in the assistant message:
The Kimi K3 series always enables thinking and Preserved Thinking, and uses the top-level reasoning_effort field ("low", "high", or "max"; default "max"). It does not use the K2.x thinking parameters below. kimi-k2.6 and kimi-k2.7-code support thinking mode: the model first outputs its reasoning process (reasoning_content) before producing the final answer.K2.x request parameters
Field
Type
Description
thinking.type
"enabled" | "disabled"
Thinking switch (kimi-k2.7-code is always enabled and cannot be disabled)
thinking.keep
null | "all"
Preserved Thinking: whether to retain historical reasoning_content in context. kimi-k2.6 defaults to null (not kept) and accepts "all"; kimi-k2.7-code is fixed at "all" (kept), other values return an error
Reasoning process (returned only when thinking mode is enabled)
{ "choices": [{ "message": { "role": "assistant", "content": "1 + 1 = 2", "reasoning_content": "The user is asking a very simple math question: \"What is 1+1?\"\n\nThis is as basic as it gets. The answer is 2. There's no need for any elaborate explanation, headers, bullet points, or lengthy response. A simple, direct answer is appropriate here.\n\nI could just say \"2\" or \"1+1 = 2\" — keeping it brief and conversational since this is a casual chat context." } }]}
When using a thinking model in multi-turn conversations, always preserve the reasoning_content of each historical assistant message in messages, otherwise the model may lose reasoning context.
Set stream: true to enable streaming output. The model returns content incrementally in Server-Sent Events (SSE) format. Recommended for scenarios requiring real-time feedback, such as chat, code generation, and long text output.
completion = client.chat.completions.create( model="kimi-k3.1-pro", messages=[{"role": "user", "content": "Explain what recursion is."}], stream=True, stream_options={"include_usage": True},)for chunk in completion: if chunk.usage is not None: print("\nusage:", chunk.usage.model_dump()) if not chunk.choices: continue delta = chunk.choices[0].delta reasoning: str = getattr(delta, "reasoning_content", None) or "" if reasoning: print(reasoning, end="") if delta.content: print(delta.content, end="")
SSE Response FormatEach line starts with data:, followed by a JSON object. Receive delta.reasoning_content before delta.content; finish_reason="stop" marks the end of generation. The subsequent usage chunk has empty choices and reports usage at the top level:
stream_optionsUse stream_options: {"include_usage": true} to receive an additional usage field in the last chunk (before data: [DONE]), showing the token consumption of the request:
Partial Mode (Prefill) allows you to prefill an output prefix in the last assistant message of messages, guiding the model to continue generation in the format or direction you expect.How to EnableAppend an role="assistant" message at the end of the messages array, and set partial: true:
The model continues after the prefilled code-block prefix. The returned content excludes that prefix.Common Use Cases
Force the model to start with a specific format (e.g., JSON’s { or a Markdown code-block prefix)
Maintain role name prefixes in role-play scenarios (combined with the name field)
When finish_reason="length" and answer content exists, use the generated content as the prefix and pass back the original reasoning_content to continue
Do not mix Partial Mode with response_format={"type": "json_object"}, as this may lead to unexpected model responses. To guide JSON output, use Structured Output directly, or set partial: true and prefill { separately.
The Authorization header expects a Bearer token. Use an MOONSHOT_API_KEY as the token. This is a server-side secret key. Generate one on the API keys page in your dashboard.
A client-generated random nonce (a UUID v4 is recommended). Sending it enables Request Signature: the Kimi API returns Msh-Request-Timestamp and Msh-Request-Signature in the response headers, which can later be used to prove that the request was handled by the Kimi API. Exactly one non-empty header value is allowed; if the value is invalid, the request proceeds normally but the headers above are not returned. See Verify Request Signature.
Whether to return log probabilities of the output tokens. If true, the log probability of each output token is returned in the logprobs field of the response message.
An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true when this parameter is used.
Configuration for a Predicted Output, which can greatly improve response times when large parts of the model response are known ahead of time (for example, regenerating a file with only minor changes).
The maximum number of tokens to generate for the chat completion. The default varies by model: for Kimi K3-series models (kimi-k3.1-pro, kimi-k3.1-pro-highspeed, kimi-k3) it defaults to 131072 and can be set up to 1048576. If the result reaches the maximum number of tokens without ending, the finish reason will be "length"; otherwise, it will be "stop". This refers to the length of tokens you expect us to return, not the total length of input plus output. If the sum of the input token count (prompt_tokens) and max_completion_tokens exceeds the model context window, the API automatically lowers the generation limit for the current request to fit the remaining context space and continues processing the request. The input token count itself must be less than the model context window size.
Controls the model output format. Default is {"type": "text"} for plain text output. Set to {"type": "json_object"} to enable JSON mode, ensuring output is a valid JSON object (you must guide the model to output JSON in the prompt). Set to {"type": "json_schema"} to enable Structured Output, constraining output to match a specified JSON Schema (recommended, requires the json_schema field). If you encounter schema validation issues, please submit feedback at walle GitHub Issues (https://github.com/MoonshotAI/walle/issues).
Stop words, which will halt the output when a full match is found. The matched words themselves will not be output. A maximum of 5 strings is allowed, and each string must not exceed 32 bytes
Used to cache responses for similar requests to optimize cache hit rates. For Coding Agents, this is typically a session id or task id representing a single session; if the session is exited and later resumed, this value should remain the same. For Kimi Code Plan, this field is required to improve cache hit rates. For other agents involving multi-turn conversations, it is also recommended to implement this field
Context cache write options. When omitted, cache write is enabled by default (5m tier): the system automatically writes the request prefix to the 5m cache tier
A stable identifier used to help detect users of your application that may be violating usage policies. The ID should be a string that uniquely identifies each user. It is recommended to hash the username or email address to avoid sending any identifying information
Controls whether the model calls tools. auto (default): the model decides whether to call tools; none: no tool calls; required: force a tool call; or pass an object specifying a particular function to force that tool call.
{"docsConfig":{"theme":"luma","$schema":"https://mintlify.com/docs.json","name":"Kimi API Platform","description":"Kimi K3.1 Pro is our flagship model for long-horizon coding and end-to-end knowledge work, with a 1M-token context window and industry-leading intelligence. The Kimi API Platform provides K3.1 Pro, the previous-generation K3, K2.7 Code, K2.6 and other large language model APIs, supporting long context, multimodal understanding, and Tool Calling.","colors":{"primary":"#111111","light":"#F5F5F5","dark":"#111111"},"logo":{"light":"https://mintcdn.com/moonshotai/X_5b_eA1iuJP595e/assets/logo/light.svg?fit=max\u0026auto=format\u0026n=X_5b_eA1iuJP595e\u0026q=85\u0026s=f68cf2d80f8d7f0363e088d2b988a598","dark":"https://mintcdn.com/moonshotai/X_5b_eA1iuJP595e/assets/logo/dark.svg?fit=max\u0026auto=format\u0026n=X_5b_eA1iuJP595e\u0026q=85\u0026s=297861f343cd86556341fb85b17cb13d","href":"https://platform.kimi.ai"},"favicon":{"light":"https://mintcdn.com/moonshotai/X_5b_eA1iuJP595e/assets/pics/favicon.ico?fit=max\u0026auto=format\u0026n=X_5b_eA1iuJP595e\u0026q=85\u0026s=f5dbc381f82faaf2356c1d1bd7199526","dark":"https://mintcdn.com/moonshotai/X_5b_eA1iuJP595e/assets/pics/favicon-dark.ico?fit=max\u0026auto=format\u0026n=X_5b_eA1iuJP595e\u0026q=85\u0026s=0330e19f739be705f4a0bacdbdea87a3"},"api":{"openapi":["openapi.json","admin-api/openapi.yaml"],"examples":{"defaults":"required"}},"navbar":{"links":[{"href":"https://www.kimi.com/membership/pricing?from=platform_page\u0026open=business","label":"Kimi Business"},{"href":"https://platform.kimi.ai/contact-sales","label":"Contact Sales"},{"href":"https://platform.kimi.ai/console/account","label":"User Center"}]},"footer":{"socials":{"x":"https://x.com/Kimi_Moonshot","github":"https://github.com/MoonshotAI","linkedin":"https://www.linkedin.com/company/kimi-ai-linkedin","discord":"https://discord.com/invite/TYU2fdJykW?source=docs_footer","website":"https://forum.moonshot.ai/?source=docs_footer"}},"seo":{"metatags":{"og:site_name":"Kimi API Platform","og:locale":"en-US","og:image":"https://platform.kimi.ai/og.png?v=1","og:image:alt":"Kimi API Platform","robots":"index,follow","canonical":"https://platform.kimi.ai/docs","description":"Kimi K3.1 Pro is our flagship model for long-horizon coding and end-to-end knowledge work, with a 1M-token context window and industry-leading intelligence. The Kimi API Platform provides K3.1 Pro, the previous-generation K3, K2.7 Code, K2.6 and other large language model APIs, supporting long context, multimodal understanding, and Tool Calling.","keywords":"Kimi K3.1 Pro,kimi-k3.1-pro,Kimi K3,Moonshot AI,K3 Large Language Model,AI API,Tool Calling,Code Generation,Intelligent Dialogue,AI Agent,Open-source Model,Long Context,Claw Bot"}},"styling":{"eyebrows":"breadcrumbs","latex":false},"integrations":{"clarity":{"projectId":"r1wlk72gay"},"ga4":{"measurementId":"G-Z0ZTEN03PZ"}},"banner":{"content":"🎉 Kimi K3.1 Pro has launched! [Start exploring now!](https://platform.kimi.ai/docs/guide/kimi-k3-1-pro-quickstart)","dismissible":true},"errors":{"404":{"redirect":true}},"contextual":{"options":["copy","view",{"title":"Open in Kimi","description":"Ask questions about this page","icon":"/assets/logo/kimi-context.svg","href":{"base":"https://www.kimi.ai/","query":[{"key":"prefill_prompt","value":"Read from https://platform.kimi.ai/docs$path so I can ask questions about it."}]}}],"display":"header"},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"moonshotai","hasAudioNarration":false,"actualSubdomain":"moonshotai","customDomains":["platform.kimi.ai"],"gitSource":{"type":"github","owner":"moonshotai","repo":"kimi-platform-docs","deployBranch":"master","contentDirectory":"global","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6aeaf204821d0792126bbff2","collectionId":"e2d5515b-2814-4947-9bfe-9fd2d5a040be","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6aeaf204821d0792126bbff2"},"feedback":{"thumbs":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"REMOVE_BRANDING":{"status":"ENABLED"},"CONTEXTUAL_FEEDBACK":{"status":"ENABLED"},"CODE_SNIPPET_FEEDBACK":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6aeaf204821d0792126bbff2","clientVersion":"0.0.4076","searchFilterCounts":[{"language":"default","tag":"API Reference","count":61},{"language":"default","tag":"Admin API","count":32},{"language":"default","tag":"Guides","count":30},{"language":"default","tag":"Organization","count":24},{"language":"default","tag":"Resources","count":17},{"language":"default","tag":"Learning and support","count":14},{"language":"default","tag":"Help Center","count":12},{"language":"default","tag":"Model Capabilities","count":9},{"language":"default","tag":"Models \u0026 Pricing","count":9},{"language":"default","tag":"Members \u0026 Invitations","count":7}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"/docs","hasChatPermissions":false,"hasWebMcpPermissions":true,"toggles":[],"googleFontsInlined":false},"customCss":[{"filePath":"custom.css","content":":root{--brand-primary: #111111;--brand-primary-strong: #2a2a2a;--brand-primary-soft: rgba(17, 17, 17, 0.08);--brand-text: #171717;--brand-text-muted: #5f5f68;--brand-border: #e5e7eb;--brand-border-strong: #d4d4d8;--brand-surface: #f5f5f5;--brand-card-bg: rgba(255, 255, 255, 0.9);--brand-overlay: linear-gradient(to top, rgba(10, 10, 10, 0.78), rgba(10, 10, 10, 0.28), transparent)}.dark,[data-theme=\"dark\"]{--brand-primary: #f5f5f5;--brand-primary-strong: #ffffff;--brand-primary-soft: rgba(245, 245, 245, 0.14);--brand-text: #fafafa;--brand-text-muted: #a1a1aa;--brand-border: #303038;--brand-border-strong: #3f3f46;--brand-surface: #151515;--brand-card-bg: rgba(24, 24, 27, 0.88);--brand-overlay: linear-gradient(to top, rgba(0, 0, 0, 0.84), rgba(0, 0, 0, 0.3), transparent)}#footer>*>div:last-child,#footer>*>div:nth-last-child(2){display:none!important}#footer a[href^=\"https://forum.moonshot.ai/\"] svg{display:none!important}#footer a[href^=\"https://forum.moonshot.ai/\"]::before{content:\"\";display:block;width:1.25rem;height:1.25rem;background-color:currentColor;-webkit-mask:url(\"/assets/icons/community.svg\") center / contain no-repeat;mask:url(\"/assets/icons/community.svg\") center / contain no-repeat}#search-bar-entry,#search-bar-entry-mobile{border:1px solid var(--brand-border)!important;background:var(--brand-card-bg)!important;box-shadow:none!important}#search-input{color:var(--brand-text)!important}#search-input::placeholder{color:var(--brand-text-muted)!important}#topbar,#topbar-content-container,#topbar-content-wrapper{color:var(--brand-text)!important}@media (min-width: 1024px){#sidebar{top:calc(7rem + var(--banner-height, 0px))!important}}#sidebar-content li[data-active]{background:var(--brand-primary-soft)!important;border-radius:14px}#sidebar-content li[data-active] a,#sidebar-content li[data-active] button{color:var(--brand-primary)!important}#sidebar-content a,#sidebar-content button{font-weight:inherit!important;text-shadow:none!important}.sidebar-group[data-active]>.sidebar-group-header,.sidebar-group[data-active]>.sidebar-group-header *{color:var(--brand-primary)!important}.method-nav-pill,.method-pill{border-radius:999px!important;box-shadow:none!important}#request-example,#response-example,#api-playground-input,#panel,#page-context-menu-button{border-color:var(--brand-border)!important}#request-example,#response-example,#api-playground-input{background:var(--brand-card-bg)!important}.dark .method-nav-pill,.dark .method-pill,[data-theme=\"dark\"] .method-nav-pill,[data-theme=\"dark\"] .method-pill{border-color:transparent!important}.dark li[role=\"tab\"][aria-selected=\"true\"]>div,[data-theme=\"dark\"] li[role=\"tab\"][aria-selected=\"true\"]>div{color:#ffffff!important;border-color:#ffffff!important}.nav-tabs-item[data-active],.mobile-nav-tabs-item[data-active]{color:var(--brand-primary)!important}.navbar-link:hover,.nav-tabs-item:hover,.mobile-nav-tabs-item:hover{color:var(--brand-primary)!important}.toc-item[data-active],.toc-item[data-active-deepest]{color:var(--brand-primary)!important}.toc-item[data-active] a,.toc-item[data-active-deepest] a{color:var(--brand-primary)!important}#header>div.mt-2.prose{font-size:1rem;line-height:1.5rem}#header>div.mt-2.prose{color:#73737c}.dark #header>div.mt-2.prose,[data-theme=\"dark\"] #header>div.mt-2.prose{color:#a1a1aa}.mdx-content a{color:var(--brand-primary);text-decoration-color:color-mix(in srgb, var(--brand-primary) 58%, transparent)}.mdx-content a:hover{color:var(--brand-primary-strong);text-decoration-color:color-mix(in srgb, var(--brand-primary-strong) 72%, transparent)}.mdx-content a strong,.mdx-content a b,.mdx-content a code{color:inherit}.quickstart-cta-wrap{display:flex;justify-content:center;margin:48px 0 64px}.mdx-content .quickstart-cta{display:inline-flex;align-items:center;justify-content:center;padding:10px 20px;border-radius:8px;background:var(--brand-primary);color:var(--brand-surface);font-size:14px;font-weight:500;line-height:1.25;text-decoration:none}.mdx-content .quickstart-cta:hover{background:var(--brand-primary-strong);color:var(--brand-surface)}.code-block,pre{border-color:var(--brand-border)!important}code:not(pre code){background:var(--brand-surface)!important;border:1px solid var(--brand-border);color:var(--brand-text)!important}#page-context-menu-button:hover,.pagination-next:hover,.pagination-prev:hover,.topbar-cta-button:hover{border-color:var(--brand-primary)!important}.overview-page{color:var(--brand-text)}.overview-page a{border-bottom:none!important;box-shadow:none!important;text-decoration:none!important}.overview-page .overview-overlay-link{position:absolute!important;inset:0!important;display:block!important;border:0!important;border-bottom:0!important;box-shadow:none!important;text-decoration:none!important;z-index:4!important}.overview-page .overview-grid-2,.overview-page .overview-grid-3,.overview-page .overview-grid-4{display:grid;align-items:stretch;gap:16px}.overview-page .overview-grid-2{grid-template-columns:repeat(2, minmax(0, 1fr))}.overview-page .overview-grid-3{grid-template-columns:repeat(3, minmax(0, 1fr))}.overview-page .overview-grid-4{grid-template-columns:repeat(2, minmax(0, 1fr))}.overview-page .overview-link-card,.overview-page .overview-resource-card{position:relative;overflow:hidden;display:flex;height:100%;border:1px solid var(--brand-border);border-radius:12px;background:var(--brand-card-bg);backdrop-filter:blur(10px);transition:border-color 0.2s, background-color 0.2s, box-shadow 0.2s}.overview-page .overview-link-card:hover,.overview-page .overview-resource-card:hover{border-color:var(--brand-primary);box-shadow:0 10px 30px rgba(15, 23, 42, 0.08)}.overview-page .overview-link-card__body,.overview-page .overview-resource-card__body{display:flex;padding:20px 16px;width:100%;flex-direction:row;gap:12px;align-items:flex-start}.overview-page .overview-link-card__content{display:flex;flex:1;flex-direction:column}.overview-page .overview-link-card__icon{display:flex;width:24px;min-width:24px;align-items:center;justify-content:center;line-height:1;margin-top:3px;color:var(--brand-text-muted)}.overview-page .overview-link-card__title,.overview-page .overview-resource-card__title{font-size:16px;font-weight:500;line-height:1.2;color:var(--brand-text)}.overview-page .overview-link-card__description,.overview-page .overview-resource-card__description{margin-top:4px;font-size:14px;color:var(--brand-text-muted);line-height:1.4}.overview-page .overview-model-card{position:relative;overflow:hidden;border:1px solid var(--brand-border);border-radius:12px;background:var(--brand-surface)}.overview-page .overview-model-card__media{position:relative;aspect-ratio:123 / 92;line-height:0}.overview-page .overview-model-card__image{display:block;width:100%;height:100%;object-fit:cover;transition:transform 0.5s}.overview-page .overview-model-card:hover .overview-model-card__image{transform:scale(1.05)}.overview-page .overview-model-card__overlay{position:absolute;inset:0;display:flex;align-items:flex-end;background:var(--brand-overlay)}.overview-page .overview-model-card__content{width:100%;padding:16px}.overview-page .overview-model-card__name{color:white;font-weight:600;line-height:1.2;font-size:16px}.overview-page .overview-model-card__tag-row{margin-top:8px;line-height:1}.overview-page .overview-hero-card{background:var(--brand-surface);border-color:var(--brand-border)!important}.overview-page .overview-hero-card__cta{display:inline-flex;align-items:center;gap:6px;padding:10px 20px;border:1px solid rgba(255, 255, 255, 0.14);border-radius:8px;background:rgba(255, 255, 255, 0.96);color:#111111!important;font-size:14px;font-weight:500;white-space:nowrap;position:relative;z-index:10;transition:transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease}.overview-page .overview-hero-card__cta:hover{background:#ffffff;border-color:rgba(255, 255, 255, 0.3);transform:translateY(-1px)}.overview-page .overview-section-link{color:var(--brand-primary)!important;text-decoration:underline!important;text-underline-offset:0.18em}.overview-page .overview-section-link:hover{color:var(--brand-primary-strong)!important}.overview-page .overview-resource-card a,.overview-page .overview-link-card a,.overview-page .overview-model-card a{color:inherit!important}@media (max-width: 1100px){.overview-page .overview-grid-3{grid-template-columns:repeat(2, minmax(0, 1fr))}}#choose-the-right-api+div table:first-of-type{min-width:680px;table-layout:fixed}#choose-the-right-api+div table:first-of-type th,#choose-the-right-api+div table:first-of-type td{min-width:0}#choose-the-right-api+div table:first-of-type th:nth-child(1),#choose-the-right-api+div table:first-of-type td:nth-child(1){width:16%}#choose-the-right-api+div table:first-of-type th:nth-child(2),#choose-the-right-api+div table:first-of-type td:nth-child(2){width:32%}#choose-the-right-api+div table:first-of-type td:nth-child(2),#choose-the-right-api+div table:first-of-type td:nth-child(2) code{white-space:nowrap}#content-side-layout:has(.code-group){display:none!important}@media (max-width: 700px){.overview-page .overview-grid-2,.overview-page .overview-grid-3,.overview-page .overview-grid-4{grid-template-columns:1fr}}.doc-table-wrap{width:100%;max-width:100%}.doc-table-wrap table{display:table!important;width:100%!important;max-width:100%!important;min-width:0!important;table-layout:fixed!important;margin:0!important}.doc-table-wrap th,.doc-table-wrap td{white-space:normal!important;overflow-wrap:anywhere;word-break:break-word;text-align:left!important;vertical-align:middle}.doc-table-wrap td ul{margin-top:0!important;margin-bottom:0!important}.doc-table-bordered{border:1px solid rgba(128, 128, 128, 0.25);container-type:inline-size}.doc-table-bordered th,.doc-table-bordered td{padding:12px 16px!important}.doc-table-bordered th:first-child,.doc-table-bordered td:first-child{border-right:1px solid rgba(128, 128, 128, 0.25)}.doc-table-bordered .doc-table-group-start,.doc-table-bordered thead tr.doc-table-groups th:nth-child(n+3){border-left:1px solid rgba(128, 128, 128, 0.25)}.doc-table-corner-sub{font-weight:400;opacity:0.6}.doc-table-unit{opacity:0.55;font-size:0.85em}@container (min-width: 840px){.doc-table-bordered .doc-table-price{white-space:nowrap}}.doc-table-wrap thead tr.doc-table-groups th{text-align:left!important;font-weight:600;border-bottom:1px solid rgba(128, 128, 128, 0.25)}.doc-table-wrap thead tr.doc-table-groups th:empty{border-bottom:none}.doc-table-bordered thead tr.doc-table-groups th{background-color:rgba(128, 128, 128, 0.16)}.doc-table-bordered thead tr:not(.doc-table-groups) th{background-color:rgba(128, 128, 128, 0.06)}@media (max-width: 900px){.doc-table-wrap th,.doc-table-wrap td{padding:10px 8px!important;font-size:13px;line-height:1.45}}@media (max-width: 640px){.doc-table-wrap{width:100%}.doc-table-wrap th,.doc-table-wrap td{padding:8px 6px!important;font-size:12px;line-height:1.4}.doc-table-wrap td:first-child,.doc-table-wrap th:first-child{word-break:break-all;overflow-wrap:anywhere}.doc-table-wrap code{font-size:11px;white-space:normal!important;word-break:break-all}}.sidebar-group-header{font-size:0.875rem!important}nav[aria-label=\"Pages\"] ul.bottom-0.border-t{display:none!important}li.navbar-link>a{border:1px solid var(--brand-border, #e5e7eb);border-radius:9999px;padding:0.3rem 0.9rem}li.navbar-link>a:hover{border-color:var(--brand-primary)!important;color:var(--brand-primary)!important}div.relative:has(>#search-bar-entry){flex:none!important;justify-content:flex-end!important}#search-bar-entry{width:2.25rem!important;min-width:2.25rem!important;flex:none!important;padding:0!important;justify-content:center!important;border-radius:9999px!important}#search-bar-entry *{font-size:0!important}#search-bar-entry kbd{display:none!important}div[data-top-chrome]{padding-left:1rem!important;padding-right:1rem!important}#search-bar-entry{width:1.75rem!important;min-width:1.75rem!important;height:1.75rem!important;display:flex!important;align-items:center!important;justify-content:center!important}#search-bar-entry>div{margin:0!important;gap:0!important}#search-bar-entry{width:2.1rem!important;min-width:2.1rem!important;height:2.1rem!important}#search-bar-entry>div{flex:none!important;width:auto!important;justify-content:center!important}#search-bar-entry svg{display:block!important;margin:0 auto!important}#theme-preference-menu-trigger{position:fixed!important;left:1rem;bottom:1rem;z-index:40;background:var(--brand-surface, #ffffff)!important;border:1px solid var(--brand-border, #e5e7eb)!important}#theme-preference-menu-trigger{left:auto!important;right:1rem!important}@media (min-width: 1024px){#content-area{margin-left:auto!important;margin-right:auto!important}}@media (min-width: 1280px){#content-area{max-width:56rem!important}#content-side-layout{margin-right:1.5rem!important;padding-left:1.5rem!important}}@media (min-width: 91.875rem){#sidebar-content{width:18rem!important}#body-content{padding-left:18rem!important}}.strike-price{white-space:nowrap}.strike-price-original{color:#9ca3af;margin-right:0.375rem}.strike-price-current{color:#dc2626;font-weight:600}.dark .strike-price-current,[data-theme=\"dark\"] .strike-price-current{color:#f87171}#banner button{width:1.25rem!important;height:1.25rem!important;right:0.75rem!important;border-radius:9999px!important;opacity:0.55;transition:opacity 0.15s ease, background-color 0.15s ease}#banner button:hover{opacity:1;background:rgba(255, 255, 255, 0.14)!important}#banner button svg{width:12px!important;height:12px!important;stroke-width:1.5}@media (min-width: 1280px){#content-container:not(:has(#table-of-contents-layout))::after{content:\"\";flex:none;width:19.5rem}}.video-intro{margin-top:4px;font-size:0.85em;line-height:1.6}.video-intro-toggle{display:none}.video-intro>label{cursor:pointer;color:#888}.video-intro>label::before{content:\"▸ \"}.video-intro-toggle:checked+label::before{content:\"▾ \"}.video-intro-body{display:none;color:#666;margin-top:4px}.video-intro-toggle:checked~.video-intro-body{display:block}.video-intro-body p{margin:0 0 6px}.video-grid video{margin:0}"}],"page":{"pagePath":"api/chat","slug":"/api/chat","pageMetadata":{"title":"Chat Completions API","sidebarTitle":"Chat Completions API","description":"Create a chat completion: send messages to Kimi models and get replies, with streaming, tool calling, and vision input.","openapi":"POST /v1/chat/completions","href":"/api/chat"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Create a chat completion: send messages to Kimi models and get replies, with streaming, tool calling, and vision input.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{Accordion,CodeBlock,CodeGroup,Heading,Note,Table,Warning}=_components;if(!Accordion)_missingMdxReference(`Accordion`,true);if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Create a chat completion request. The model generates a response based on the provided message list.`}),`\n`,_jsxs(Accordion,{title:`Content Field Description`,id:`content-field-description`,children:[_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`content`}),` field supports the following two forms:`]}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Plain text string`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{ `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Hello\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})]}),`\n`]})})}),_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Array of objects`}),` (for multimodal input)`]}),_jsxs(_components.p,{children:[`Each element in the array is distinguished by the `,_jsx(_components.code,{children:`type`}),` field:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`7`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"text\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"text\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Describe this image\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"image_url\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"image_url\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"url\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"data:image/png;base64,...\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"video_url\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"video_url\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"url\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"data:video/mp4;base64,...\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } }`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),_jsxs(_components.p,{children:[_jsx(_components.code,{children:`image_url`}),` and `,_jsx(_components.code,{children:`video_url`}),` also support passing a string directly, equivalent to the `,_jsx(_components.code,{children:`url`}),` field in object form:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{ `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"image_url\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"image_url\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"data:image/png;base64,...\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})]}),`\n`]})})}),_jsx(Heading,{level:`4`,id:`parameter-description`,children:`Parameter Description`}),_jsx(_components.p,{children:`Each element in the array has the following fields:`}),_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Required`}),_jsx(_components.th,{children:`Description`}),_jsx(_components.th,{children:`Type`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`type`})}),_jsx(_components.td,{children:`required`}),_jsx(_components.td,{children:`Content type`}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`\"text\"`}),` | `,_jsx(_components.code,{children:`\"image_url\"`}),` | `,_jsx(_components.code,{children:`\"video_url\"`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`text`})}),_jsxs(_components.td,{children:[`required when `,_jsx(_components.code,{children:`type=text`})]}),_jsx(_components.td,{children:`Text content`}),_jsx(_components.td,{children:`string`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`image_url`})}),_jsxs(_components.td,{children:[`required when `,_jsx(_components.code,{children:`type=image_url`})]}),_jsxs(_components.td,{children:[`For transmitting images. Supports object form `,_jsx(_components.code,{children:`{\"url\": \"...\"}`}),` or a URL string directly`]}),_jsx(_components.td,{children:`object | string`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`video_url`})}),_jsxs(_components.td,{children:[`required when `,_jsx(_components.code,{children:`type=video_url`})]}),_jsxs(_components.td,{children:[`For transmitting videos. Supports object form `,_jsx(_components.code,{children:`{\"url\": \"...\"}`}),` or a URL string directly`]}),_jsx(_components.td,{children:`object | string`})]})]})]}),_jsxs(_components.p,{children:[`When `,_jsx(_components.code,{children:`image_url`}),` is passed as an object, its fields are:`]}),_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Required`}),_jsx(_components.th,{children:`Description`}),_jsx(_components.th,{children:`Type`})]})}),_jsx(_components.tbody,{children:_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`url`})}),_jsx(_components.td,{children:`required`}),_jsx(_components.td,{children:`Image content specified via base64 encoding or file id`}),_jsx(_components.td,{children:`string`})]})})]}),_jsxs(_components.p,{children:[`When `,_jsx(_components.code,{children:`video_url`}),` is passed as an object, its fields are:`]}),_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Required`}),_jsx(_components.th,{children:`Description`}),_jsx(_components.th,{children:`Type`})]})}),_jsx(_components.tbody,{children:_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`url`})}),_jsx(_components.td,{children:`required`}),_jsxs(_components.td,{children:[`Video content specified via base64 encoding or file id, for example `,_jsx(_components.code,{children:`data:video/mp4;base64,...`})]}),_jsx(_components.td,{children:`string`})]})})]}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`Both the object form (`,_jsx(_components.code,{children:`url`}),` field) and the string shorthand support the following formats:`]}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Base64 encoding: `,_jsx(_components.code,{children:`data:image/png;base64,...`}),` or `,_jsx(_components.code,{children:`data:video/mp4;base64,...`})]}),`\n`,_jsxs(_components.li,{children:[`File reference: `,_jsx(_components.code,{children:`ms://\u003cfile_id>`})]}),`\n`]}),_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/guide/use-kimi-vision-model`,children:`Use the Kimi Vision Model`}),`.`]})]}),_jsx(Heading,{level:`4`,id:`usage-example`,children:`Usage Example`}),_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`python`,expandable:`true`,numberOfLines:`36`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`36`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` os`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` base64`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` openai `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAI`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` openai.types.chat `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ChatCompletion`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`client: OpenAI `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAI(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` api_key`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`os.environ.get(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"MOONSHOT_API_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` base_url`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://api.moonshot.ai/v1\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Encode the image to base64`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`with`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` open`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"your_image_path\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"rb\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` f:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` img_base: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` base64.b64encode(f.read()).decode(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"utf-8\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`response: ChatCompletion `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.chat.completions.create(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"kimi-k3.1-pro\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"image_url\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"image_url\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"url\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"data:image/jpeg;base64,`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`img_base`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"text\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"text\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Describe this image\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ],`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ],`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(response.choices[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].message.content)`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`curl`,expandable:`true`,numberOfLines:`23`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`23`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` https://api.moonshot.ai/v1/chat/completions`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/json\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: Bearer `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$MOONSHOT_API_KEY`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"model\": \"kimi-k3.1-pro\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"messages\": [`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` {`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"role\": \"user\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"content\": [`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` {`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"type\": \"image_url\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"image_url\": {`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"url\": \"data:image/jpeg;base64,/9j/4AAQ...\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` {`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"type\": \"text\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"text\": \"Describe this image\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }'`})}),`\n`]})})}),_jsx(CodeBlock,{filename:`node.js`,expandable:`true`,numberOfLines:`36`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`36`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` fs`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` require`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"fs\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` OpenAI`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` require`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"openai\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` client`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` OpenAI`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` apiKey:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` process`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`env`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`MOONSHOT_API_KEY`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` baseURL:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"https://api.moonshot.ai/v1\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` function`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` main`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Encode the image to base64`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` imgBase`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` fs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`readFileSync`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"your_image_path\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`).`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`toString`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"base64\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` response`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` client`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`chat`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`completions`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`create`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` model:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"kimi-k3.1-pro\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` messages:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` role:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` content:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` type:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"image_url\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` image_url:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` url:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `data:image/jpeg;base64,\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`imgBase`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` type:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"text\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` text:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Describe this image\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ],`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ],`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`response`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`choices`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`message`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`content`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`main`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`]})})})]})]}),`\n`,_jsxs(Accordion,{title:`Response Format`,id:`response-format`,children:[_jsx(Heading,{level:`3`,id:`non-streaming-response`,children:`Non-streaming Response`}),_jsx(CodeBlock,{filename:``,numberOfLines:`28`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`28`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"chatcmpl-6adb0d430e590c70159c6ca1\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"object\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"chat.completion\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"created\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1792740680`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"model\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"kimi-k3.1-pro\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"choices\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"index\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"message\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"1 + 1 = 2\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"assistant\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"reasoning_content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"The user is asking a very simple math question: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`What is 1+1?`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"\\\\n\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`This is as basic as it gets. The answer is 2. There's no need for any elaborate explanation, headers, bullet points, or lengthy response. A simple, direct answer is appropriate here.`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`I could just say `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`2`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` or `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`1+1 = 2`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` — keeping it brief and conversational since this is a casual chat context.\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"finish_reason\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"stop\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ],`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"usage\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"completion_tokens\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`112`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"prompt_tokens\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`373`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"total_tokens\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`485`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"completion_tokens_details\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"reasoning_tokens\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`90`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"prompt_tokens_details\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"cache_write_tokens\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`256`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),_jsx(Heading,{level:`3`,id:`streaming-response`,children:`Streaming Response`}),_jsxs(_components.p,{children:[`Set `,_jsx(_components.code,{children:`stream=true`}),` and `,_jsx(_components.code,{children:`stream_options.include_usage=true`}),`. Reasoning arrives in `,_jsx(_components.code,{children:`reasoning_content`}),`, followed by the answer in `,_jsx(_components.code,{children:`content`}),`. The final usage chunk has `,_jsx(_components.code,{children:`choices: []`}),` and reports totals in the top-level `,_jsx(_components.code,{children:`usage`}),`.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`14`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`14`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`data: {\"id\":\"chatcmpl-6adb0ef47c3c1358b6a07603\",\"object\":\"chat.completion.chunk\",\"created\":1792741110,\"model\":\"kimi-k3.1-pro\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"finish_reason\":null}],\"system_fingerprint\":\"fpv0_e7278693\"}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`data: {\"id\":\"chatcmpl-6adb0ef47c3c1358b6a07603\",\"object\":\"chat.completion.chunk\",\"created\":1792741110,\"model\":\"kimi-k3.1-pro\",\"choices\":[{\"index\":0,\"delta\":{\"reasoning_content\":\"The\"},\"finish_reason\":null}],\"system_fingerprint\":\"fpv0_e7278693\"}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`...`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`data: {\"id\":\"chatcmpl-6adb0ef47c3c1358b6a07603\",\"object\":\"chat.completion.chunk\",\"created\":1792741110,\"model\":\"kimi-k3.1-pro\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"1\"},\"finish_reason\":null}],\"system_fingerprint\":\"fpv0_e7278693\"}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`...`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`data: {\"id\":\"chatcmpl-6adb0ef47c3c1358b6a07603\",\"object\":\"chat.completion.chunk\",\"created\":1792741110,\"model\":\"kimi-k3.1-pro\",\"choices\":[],\"usage\":{\"prompt_tokens\":373,\"completion_tokens\":93,\"total_tokens\":466,\"completion_tokens_details\":{\"reasoning_tokens\":71},\"prompt_tokens_details\":{\"cache_write_tokens\":256}}}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`data: [DONE]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsx(Note,{children:_jsxs(_components.p,{children:[`The model name in the response example will be returned based on the model parameter in the request. When using the `,_jsx(_components.code,{children:`kimi-k3.1-pro`}),` model, the `,_jsx(_components.code,{children:`\"model\"`}),` field in the response will show `,_jsx(_components.code,{children:`\"kimi-k3.1-pro\"`}),`.`]})})]}),`\n`,_jsxs(Accordion,{title:`Context Caching (Cache Write)`,id:`context-caching-cache-write`,children:[_jsxs(_components.p,{children:[`Cache Write is supported by `,_jsx(_components.code,{children:`kimi-k3.1-pro`}),`, `,_jsx(_components.code,{children:`kimi-k3.1-pro-highspeed`}),`, and `,_jsx(_components.code,{children:`kimi-k3`}),`. The Kimi API automatically enables context caching for repeated request prefixes; cached portions are billed at a lower price and respond faster. Use `,_jsx(_components.code,{children:`prompt_cache_options`}),` to control cache write behavior:`]}),_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Parameter`}),_jsx(_components.th,{children:`Type`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`prompt_cache_options`})}),_jsx(_components.td,{children:`object`}),_jsxs(_components.td,{children:[`Context cache write options. When omitted, cache write is enabled by default (`,_jsx(_components.code,{children:`5m`}),` tier)`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`prompt_cache_options.mode`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`\"implicit\"`})}),_jsxs(_components.td,{children:[`Cache write mode. Only `,_jsx(_components.code,{children:`implicit`}),` is supported: automatically writes the request prefix to the cache`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`prompt_cache_options.ttl`})}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`\"5m\"`}),` | `,_jsx(_components.code,{children:`\"1h\"`})]}),_jsxs(_components.td,{children:[`Lifetime of the written cache. Only `,_jsx(_components.code,{children:`5m`}),` and `,_jsx(_components.code,{children:`1h`}),` are supported (default `,_jsx(_components.code,{children:`5m`}),`); the two tiers are independent`]})]})]})]}),_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"model\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"kimi-k3.1-pro\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"messages\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [{`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Hello\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"prompt_cache_options\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"mode\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"implicit\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"ttl\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"1h\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Behavior`})}),_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`The cache is isolated per organization (org); caches are never shared across organizations.`}),`\n`,_jsx(_components.li,{children:`When a request with the same prefix hits the cache within its lifetime, the cache entry is refreshed with its original TTL. Cache hits are billed only at the cache read price, with no additional cache write charge.`}),`\n`,_jsxs(_components.li,{children:[`Cache writes are billed by TTL; see `,_jsx(_components.a,{href:`/pricing/chat`,children:`Pricing`}),` for details.`]}),`\n`,_jsx(_components.li,{children:`Manual cache clearing is not supported; cached prefixes expire automatically after at least 5 minutes of inactivity.`}),`\n`,_jsxs(_components.li,{children:[`Explicit cache breakpoints are not supported: the request is rejected (HTTP 400) if `,_jsx(_components.code,{children:`prompt_cache_breakpoint`}),` appears in `,_jsx(_components.code,{children:`content`}),`.`]}),`\n`]}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Usage fields`})}),_jsxs(_components.p,{children:[_jsx(_components.code,{children:`usage.prompt_tokens`}),` is always the total number of input tokens. Its internal breakdown is returned in `,_jsx(_components.code,{children:`prompt_tokens_details`}),`:`]}),_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Field`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`usage.prompt_tokens_details.cached_tokens`})}),_jsx(_components.td,{children:`Tokens served from the cache (cache read)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`usage.prompt_tokens_details.cache_write_tokens`})}),_jsx(_components.td,{children:`Tokens written to the cache by this request (cache write)`})]})]})]}),_jsxs(_components.p,{children:[_jsx(_components.code,{children:`cached_tokens`}),`, `,_jsx(_components.code,{children:`cache_write_tokens`}),`, and the uncached remainder are mutually exclusive and sum to `,_jsx(_components.code,{children:`prompt_tokens`}),`; the uncached remainder = `,_jsx(_components.code,{children:`prompt_tokens`}),` − `,_jsx(_components.code,{children:`cached_tokens`}),` − `,_jsx(_components.code,{children:`cache_write_tokens`}),`.`]}),_jsxs(_components.p,{children:[`In the non-streaming response above, the input is 373 tokens, including 256 cache-write tokens; output is 112 tokens, for a total of 373 + 112 = 485 tokens. Cache reads and writes are already included in `,_jsx(_components.code,{children:`prompt_tokens`}),`; output includes both reasoning and answer tokens. Do not count these tokens twice.`]}),_jsxs(_components.p,{children:[`For streaming requests, the full cache read/write breakdown is only returned in the `,_jsx(_components.code,{children:`usage`}),` field of the final chunk (set `,_jsx(_components.code,{children:`stream_options.include_usage=true`}),`). The Chat Completions response does not echo the applied mode/ttl (unlike the Responses API); keep track of the values used at request time.`]}),_jsx(Note,{children:_jsxs(_components.p,{children:[`For the mechanism behind automatic context caching, see the `,_jsx(_components.a,{href:`/guide/context-caching`,children:`Context Caching guide`}),`.`]})})]}),`\n`,_jsxs(Accordion,{title:`Multi-turn Conversations`,id:`multi-turn-conversations`,children:[_jsxs(_components.p,{children:[`The Kimi API is stateless and does not retain conversation history. To implement multi-turn dialogue, append the previous assistant reply (and any tool results, if applicable) back into the `,_jsx(_components.code,{children:`messages`}),` array before sending the next request.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`14`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`14`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`messages `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"system\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"You are Kimi.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Hello, my name is Li Lei.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`completion `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.chat.completions.create(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"kimi-k3.1-pro\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`messages)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`reply `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` completion.choices[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].message`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Preserve the full assistant reply, including reasoning_content and any tool_calls`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`messages.append(reply.model_dump(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`exclude_none`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`))`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`messages.append({`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"What is 1+1?\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`})`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`completion `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.chat.completions.create(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"kimi-k3.1-pro\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`messages)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(completion.choices[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].message.content)`})]}),`\n`]})})}),_jsx(_components.p,{children:`When the conversation history grows too long, retain only the most recent messages or compress earlier turns to avoid exceeding the model’s context limit.`}),_jsx(Note,{children:_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/guide/engage-in-multi-turn-conversations-using-kimi-api`,children:`Engage in Multi-turn Conversations`}),` for details.`]})})]}),`\n`,_jsxs(Accordion,{title:`JSON Mode`,id:`json-mode`,children:[_jsxs(_components.p,{children:[`Use the `,_jsx(_components.code,{children:`response_format`}),` parameter to constrain the model output format:`]}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`{\"type\": \"text\"}`}),` (default): plain text output`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`{\"type\": \"json_object\"}`}),`: forces a valid JSON Object output`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`{\"type\": \"json_schema\", \"json_schema\": {...}}`}),`: outputs structured data according to the given JSON Schema (Structured Output)`]}),`\n`]}),_jsxs(_components.p,{children:[`When using `,_jsx(_components.code,{children:`json_object`}),`, `,_jsx(_components.strong,{children:`you must explicitly describe the expected JSON fields and types in the system prompt or user prompt`}),`, otherwise the model may produce unexpected results.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`8`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`8`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"model\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"kimi-k3.1-pro\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"messages\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"system\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Please output JSON containing title, author, and summary fields.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Summarize this article: Recursion solves problems by breaking them into smaller instances of the same problem, with a base case that ends the calls.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ],`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"response_format\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"json_object\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),_jsx(Note,{children:_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/guide/use-json-mode-feature-of-kimi-api`,children:`Use the JSON Mode Feature of Kimi API`}),` for details.`]})})]}),`\n`,_jsxs(Accordion,{title:`Tool Use`,id:`tool-use`,children:[_jsxs(_components.p,{children:[`Pass external tools defined as JSON Schema via the `,_jsx(_components.code,{children:`tools`}),` parameter. The model can decide to invoke them when appropriate.`]}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Request example`})}),_jsx(CodeBlock,{filename:``,numberOfLines:`20`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`20`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"model\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"kimi-k3.1-pro\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"messages\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [{`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"What is the weather in Beijing today?\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"tools\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"function\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"function\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"get_weather\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"description\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Get the weather for a given city\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"parameters\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"object\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"properties\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"city\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"string\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"description\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"City name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"required\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"city\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),_jsx(_components.p,{children:_jsxs(_components.strong,{children:[_jsx(_components.code,{children:`tool_calls`}),` in the response`]})}),_jsxs(_components.p,{children:[`When `,_jsx(_components.code,{children:`finish_reason`}),` is `,_jsx(_components.code,{children:`\"tool_calls\"`}),`, the model returns a `,_jsx(_components.code,{children:`tool_calls`}),` array containing `,_jsx(_components.code,{children:`id`}),`, `,_jsx(_components.code,{children:`function.name`}),`, and `,_jsx(_components.code,{children:`function.arguments`}),`:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`20`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`20`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"choices\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"message\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"assistant\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"reasoning_content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:'\"The user is asking about the weather in Beijing today. I have a tool available called `get_weather` that can get the weather for a given city. Let me use it to find the weather in Beijing.\"'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"tool_calls\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"get_weather_0_4d9e2559\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"function\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"function\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"arguments\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"{`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`city`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`:`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`Beijing`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"get_weather\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"finish_reason\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"tool_calls\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Submitting tool execution results`})}),_jsxs(_components.p,{children:[`After executing the tool locally, first append the complete assistant message from the response (including `,_jsx(_components.code,{children:`reasoning_content`}),` and `,_jsx(_components.code,{children:`tool_calls`}),`) unchanged to the original request’s `,_jsx(_components.code,{children:`messages`}),`, then append the tool result below. The `,_jsx(_components.code,{children:`tool_call_id`}),` must match the tool-call `,_jsx(_components.code,{children:`id`}),` in the assistant message:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"tool\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"tool_call_id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"get_weather_0_4d9e2559\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Sunny, 25°C\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})]}),`\n`]})})}),_jsx(Note,{children:_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/guide/use-kimi-api-to-complete-tool-calls`,children:`Use the Kimi API to Complete Tool Calls`}),` for details.`]})})]}),`\n`,_jsxs(Accordion,{title:`Thinking Mode and Preserved Thinking`,id:`thinking-mode-and-preserved-thinking`,children:[_jsxs(_components.p,{children:[`The Kimi K3 series always enables thinking and Preserved Thinking, and uses the top-level `,_jsx(_components.code,{children:`reasoning_effort`}),` field (`,_jsx(_components.code,{children:`\"low\"`}),`, `,_jsx(_components.code,{children:`\"high\"`}),`, or `,_jsx(_components.code,{children:`\"max\"`}),`; default `,_jsx(_components.code,{children:`\"max\"`}),`). It does not use the K2.x `,_jsx(_components.code,{children:`thinking`}),` parameters below. `,_jsx(_components.code,{children:`kimi-k2.6`}),` and `,_jsx(_components.code,{children:`kimi-k2.7-code`}),` support thinking mode: the model first outputs its reasoning process (`,_jsx(_components.code,{children:`reasoning_content`}),`) before producing the final answer.`]}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`K2.x request parameters`})}),_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Field`}),_jsx(_components.th,{children:`Type`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`thinking.type`})}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`\"enabled\"`}),` | `,_jsx(_components.code,{children:`\"disabled\"`})]}),_jsxs(_components.td,{children:[`Thinking switch (`,_jsx(_components.code,{children:`kimi-k2.7-code`}),` is always `,_jsx(_components.code,{children:`enabled`}),` and cannot be disabled)`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`thinking.keep`})}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`null`}),` | `,_jsx(_components.code,{children:`\"all\"`})]}),_jsxs(_components.td,{children:[`Preserved Thinking: whether to retain historical `,_jsx(_components.code,{children:`reasoning_content`}),` in context. `,_jsx(_components.code,{children:`kimi-k2.6`}),` defaults to `,_jsx(_components.code,{children:`null`}),` (not kept) and accepts `,_jsx(_components.code,{children:`\"all\"`}),`; `,_jsx(_components.code,{children:`kimi-k2.7-code`}),` is fixed at `,_jsx(_components.code,{children:`\"all\"`}),` (kept), other values return an error`]})]})]})]}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Response fields`})}),_jsxs(_components.p,{children:[`In non-streaming responses, `,_jsx(_components.code,{children:`choices[0].message`}),` contains:`]}),_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Field`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`content`})}),_jsx(_components.td,{children:`Final answer`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`reasoning_content`})}),_jsx(_components.td,{children:`Reasoning process (returned only when thinking mode is enabled)`})]})]})]}),_jsx(CodeBlock,{filename:``,numberOfLines:`9`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`9`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"choices\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [{`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"message\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"assistant\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"1 + 1 = 2\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"reasoning_content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"The user is asking a very simple math question: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`What is 1+1?`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"\\\\n\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`This is as basic as it gets. The answer is 2. There's no need for any elaborate explanation, headers, bullet points, or lengthy response. A simple, direct answer is appropriate here.`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`I could just say `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`2`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` or `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`1+1 = 2`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` — keeping it brief and conversational since this is a casual chat context.\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),_jsx(Warning,{children:_jsxs(_components.p,{children:[`When using a thinking model in multi-turn conversations, always preserve the `,_jsx(_components.code,{children:`reasoning_content`}),` of each historical assistant message in `,_jsx(_components.code,{children:`messages`}),`, otherwise the model may lose reasoning context.`]})}),_jsx(Note,{children:_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/guide/use-thinking-models`,children:`Use the Kimi K2 Thinking Mode`}),` for details.`]})})]}),`\n`,_jsxs(Accordion,{title:`Streaming`,id:`streaming`,children:[_jsxs(_components.p,{children:[`Set `,_jsx(_components.code,{children:`stream: true`}),` to enable streaming output. The model returns content incrementally in Server-Sent Events (SSE) format. Recommended for scenarios requiring real-time feedback, such as chat, code generation, and long text output.`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`18`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`18`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`completion `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.chat.completions.create(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"kimi-k3.1-pro\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Explain what recursion is.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` stream`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` stream_options`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"include_usage\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`for`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` chunk `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`in`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` completion:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` chunk.usage `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`is`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` not`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` None`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`usage:\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, chunk.usage.model_dump())`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` not`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` chunk.choices:`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` continue`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` delta `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` chunk.choices[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].delta`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` reasoning: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`str`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` getattr`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(delta, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"reasoning_content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`None`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`or`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` reasoning:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(reasoning, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`end`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` delta.content:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(delta.content, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`end`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`SSE Response Format`})}),_jsxs(_components.p,{children:[`Each line starts with `,_jsx(_components.code,{children:`data:`}),`, followed by a JSON object. Receive `,_jsx(_components.code,{children:`delta.reasoning_content`}),` before `,_jsx(_components.code,{children:`delta.content`}),`; `,_jsx(_components.code,{children:`finish_reason=\"stop\"`}),` marks the end of generation. The subsequent usage chunk has empty `,_jsx(_components.code,{children:`choices`}),` and reports usage at the top level:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`14`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`14`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`data: {\"id\":\"chatcmpl-6adb0efaa6c470a707811b01\",\"object\":\"chat.completion.chunk\",\"created\":1792741114,\"model\":\"kimi-k3.1-pro\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"finish_reason\":null}],\"system_fingerprint\":\"fpv0_e7278693\"}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`data: {\"id\":\"chatcmpl-6adb0efaa6c470a707811b01\",\"object\":\"chat.completion.chunk\",\"created\":1792741114,\"model\":\"kimi-k3.1-pro\",\"choices\":[{\"index\":0,\"delta\":{\"reasoning_content\":\"The\"},\"finish_reason\":null}],\"system_fingerprint\":\"fpv0_e7278693\"}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`...`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`data: {\"id\":\"chatcmpl-6adb0efaa6c470a707811b01\",\"object\":\"chat.completion.chunk\",\"created\":1792741114,\"model\":\"kimi-k3.1-pro\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"#\"},\"finish_reason\":null}],\"system_fingerprint\":\"fpv0_e7278693\"}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`...`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`data: {\"id\":\"chatcmpl-6adb0efaa6c470a707811b01\",\"object\":\"chat.completion.chunk\",\"created\":1792741114,\"model\":\"kimi-k3.1-pro\",\"choices\":[],\"usage\":{\"prompt_tokens\":90,\"completion_tokens\":1524,\"total_tokens\":1614,\"completion_tokens_details\":{\"reasoning_tokens\":1007},\"prompt_tokens_details\":{\"cache_write_tokens\":0}}}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`data: [DONE]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsx(_components.p,{children:_jsx(_components.strong,{children:_jsx(_components.code,{children:`stream_options`})})}),_jsxs(_components.p,{children:[`Use `,_jsx(_components.code,{children:`stream_options: {\"include_usage\": true}`}),` to receive an additional `,_jsx(_components.code,{children:`usage`}),` field in the last chunk (before `,_jsx(_components.code,{children:`data: [DONE]`}),`), showing the token consumption of the request:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`stream`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`stream_options`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"include_usage\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})]}),`\n`]})})}),_jsx(Note,{children:_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/guide/utilize-the-streaming-output-feature-of-kimi-api`,children:`Utilize the Streaming Output Feature of Kimi API`}),` for details.`]})})]}),`\n`,_jsxs(Accordion,{title:`Partial Mode`,id:`partial-mode`,children:[_jsxs(_components.p,{children:[`Partial Mode (Prefill) allows you to prefill an output prefix in the last assistant message of `,_jsx(_components.code,{children:`messages`}),`, guiding the model to continue generation in the format or direction you expect.`]}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`How to Enable`})}),_jsxs(_components.p,{children:[`Append an `,_jsx(_components.code,{children:`role=\"assistant\"`}),` message at the end of the `,_jsx(_components.code,{children:`messages`}),` array, and set `,_jsx(_components.code,{children:`partial: true`}),`:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`7`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`completion `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.chat.completions.create(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"kimi-k3.1-pro\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Implement quicksort in Python.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"assistant\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:'\"```python'}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"partial\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),_jsxs(_components.p,{children:[`The model continues after the prefilled code-block prefix. The returned `,_jsx(_components.code,{children:`content`}),` excludes that prefix.`]}),_jsx(_components.p,{children:_jsx(_components.strong,{children:`Common Use Cases`})}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Force the model to start with a specific format (e.g., JSON’s `,_jsx(_components.code,{children:`{`}),` or a Markdown code-block prefix)`]}),`\n`,_jsxs(_components.li,{children:[`Maintain role name prefixes in role-play scenarios (combined with the `,_jsx(_components.code,{children:`name`}),` field)`]}),`\n`,_jsxs(_components.li,{children:[`When `,_jsx(_components.code,{children:`finish_reason=\"length\"`}),` and answer content exists, use the generated content as the prefix and pass back the original `,_jsx(_components.code,{children:`reasoning_content`}),` to continue`]}),`\n`]}),_jsx(Warning,{children:_jsxs(_components.p,{children:[`Do not mix Partial Mode with `,_jsx(_components.code,{children:`response_format={\"type\": \"json_object\"}`}),`, as this may lead to unexpected model responses. To guide JSON output, use `,_jsx(_components.a,{href:`/guide/response_format`,children:`Structured Output`}),` directly, or set `,_jsx(_components.code,{children:`partial: true`}),` and prefill `,_jsx(_components.code,{children:`{`}),` separately.`]})}),_jsx(Note,{children:_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/guide/use-partial-mode-feature-of-kimi-api`,children:`Use the Partial Mode Feature of Kimi API`}),` for details.`]})})]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Chat Completions API","sidebarTitle":"Chat Completions API","description":"Create a chat completion: send messages to Kimi models and get replies, with streaming, tool calling, and vision input.","openapi":"POST /v1/chat/completions","href":"/api/chat"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[],"codeExamples":{}},"jsLinks":[],"openApiReferenceData":{"operation":{"summary":"Create Chat Completion","description":"Create a chat completion: send messages to Kimi models and get replies, with streaming, tool calling, and vision input.","tags":["Chat"],"security":["ad178f96-64b2-4a2b-b5b5-5d694f0839a6"],"parameters":["c7a3441e-90d5-4bd0-abec-eae8dc0da17e"],"requestBody":"0cfb5ae7-6e96-4e13-aa54-297a182bcf35","responses":{"200":"6014d158-acf5-4baa-bee6-01d37a7bc71b","400":"c3cea2de-0250-4e5e-92d4-fb30d2aa8343","401":"eb5a2cf0-f59a-4b06-8ee6-4c64710e936b","500":"70c54761-da90-478d-ab97-4a480a40e7d3"},"method":"post","type":"path","servers":["f283f8d4-efce-425c-b24a-ee8368b5c4e3"],"path":"/v1/chat/completions","baseUrlOptions":["https://api.moonshot.ai"],"title":"Create Chat Completion","codeSamples":[],"requiredOnlyExamples":true,"requestExampleType":"generated","responseExampleType":"generated"},"dependencies":{"parameters":{"c7a3441e-90d5-4bd0-abec-eae8dc0da17e":{"name":"X-Msh-Request-Nonce","in":"header","required":false,"description":"A client-generated random nonce (a UUID v4 is recommended). Sending it enables Request Signature: the Kimi API returns `Msh-Request-Timestamp` and `Msh-Request-Signature` in the response headers, which can later be used to prove that the request was handled by the Kimi API. Exactly one non-empty header value is allowed; if the value is invalid, the request proceeds normally but the headers above are not returned. See [Verify Request Signature](/api/signatures-verify).","schema":{"type":"string","minLength":1,"example":"7d929748-0ae6-41c2-ab5d-a186498ad721","isRequired":false,"description":"A client-generated random nonce (a UUID v4 is recommended). Sending it enables Request Signature: the Kimi API returns `Msh-Request-Timestamp` and `Msh-Request-Signature` in the response headers, which can later be used to prove that the request was handled by the Kimi API. Exactly one non-empty header value is allowed; if the value is invalid, the request proceeds normally but the headers above are not returned. See [Verify Request Signature](/api/signatures-verify).","uniqueKey":"","typeLabel":"string"}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"type":"object","title":"kimi-k3.1-pro series","required":["model","messages"],"properties":{"messages":{"type":"array","description":"A list of conversation messages.","items":{"oneOf":[{"type":"object","title":"Standard message","description":"Supports standard conversation messages and system messages for dynamically loading tools.","required":["role","content"],"properties":{"role":{"type":"string","enum":["system","user","assistant","tool"],"example":"user","description":"The role of the message sender. Supports system, user, assistant, tool.","isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.role","typeLabel":"enum\u003cstring>"},"content":{"oneOf":[{"type":"string","description":"The content of the message. Can be a plain text string, or an array of objects with text/image_url/video_url types (for multimodal input)","example":"Hello","isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.0","typeLabel":"string"},{"type":"array","items":{"oneOf":[{"type":"object","title":"text","required":["type","text"],"properties":{"type":{"type":"string","enum":["text"],"isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.0.type","typeLabel":"enum\u003cstring>"},"text":{"type":"string","isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.0.text","typeLabel":"string"}},"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.0","typeLabel":"text · object"},{"type":"object","title":"image_url","required":["type","image_url"],"properties":{"type":{"type":"string","enum":["image_url"],"isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.1.type","typeLabel":"enum\u003cstring>"},"image_url":{"oneOf":[{"type":"object","required":["url"],"properties":{"url":{"type":"string","isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.1.image_url.oneOf.0.url","typeLabel":"string"}},"isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.1.image_url.oneOf.0","typeLabel":"object"},{"type":"string","isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.1.image_url.oneOf.1","typeLabel":"string"}],"isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.1.image_url","typeLabel":"object | string"}},"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.1","typeLabel":"image_url · object"},{"type":"object","title":"video_url","required":["type","video_url"],"properties":{"type":{"type":"string","enum":["video_url"],"isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.2.type","typeLabel":"enum\u003cstring>"},"video_url":{"oneOf":[{"type":"object","required":["url"],"properties":{"url":{"type":"string","isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.2.video_url.oneOf.0.url","typeLabel":"string"}},"isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.2.video_url.oneOf.0","typeLabel":"object"},{"type":"string","isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.2.video_url.oneOf.1","typeLabel":"string"}],"isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.2.video_url","typeLabel":"object | string"}},"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.2","typeLabel":"video_url · object"}],"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX]","typeLabel":"text · object | image_url · object | video_url · object"},"description":"The content of the message. Can be a plain text string, or an array of objects with text/image_url/video_url types (for multimodal input)","example":"Hello","isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content.oneOf.1","typeLabel":"(text · object | image_url · object | video_url · object)[]"}],"isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.content","typeLabel":"string | (text · object | image_url · object | video_url · object)[]"},"name":{"type":"string","default":null,"description":"Optional name for the message sender","uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.name","typeLabel":"string"},"partial":{"type":"boolean","default":false,"description":"Enable Partial Mode by setting this to true in the last assistant message","uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0.partial","typeLabel":"boolean"}},"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.0","typeLabel":"Standard message · object"},{"type":"object","title":"Dynamic tool message","description":"Supports standard conversation messages and system messages for dynamically loading tools.","required":["role","tools"],"properties":{"role":{"type":"string","enum":["system"],"description":"The role of a dynamic tool loading message. Always system.","isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.1.role","typeLabel":"enum\u003cstring>"},"tools":{"type":"array","description":"Tools available for the model to call from this message onward","items":{"type":"object","properties":{"type":{"type":"string","enum":["function"],"isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.1.tools.items.[INDEX].type","typeLabel":"enum\u003cstring>"},"function":{"type":"object","properties":{"name":{"type":"string","description":"Function name. Must follow the regex: ^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$","pattern":"^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$","isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.1.tools.items.[INDEX].function.name","typeLabel":"string"},"parameters":{"type":"object","description":"Function parameters as JSON Schema. Must conform to the [MFJS (Moonshot Flavored JSON Schema) specification](https://github.com/MoonshotAI/walle/blob/main/docs/mfjs-spec.md).","additionalProperties":true,"isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.1.tools.items.[INDEX].function.parameters","typeLabel":"object"},"description":{"type":"string","description":"Description of what the function does","uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.1.tools.items.[INDEX].function.description","typeLabel":"string"},"strict":{"type":"boolean","default":true,"description":"Whether to strictly constrain tool call arguments according to the parameters schema. Defaults to true. When false, only guarantees the output is a valid JSON object without enforcing internal structure.","uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.1.tools.items.[INDEX].function.strict","typeLabel":"boolean"}},"required":["name","parameters"],"isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.1.tools.items.[INDEX].function","typeLabel":"object"}},"required":["type","function"],"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.1.tools.items.[INDEX]","typeLabel":"object"},"isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.1.tools","typeLabel":"object[]"}},"additionalProperties":false,"uniqueKey":"oneOf.0.messages.items.[INDEX].oneOf.1","typeLabel":"Dynamic tool message · object"}],"uniqueKey":"oneOf.0.messages.items.[INDEX]","typeLabel":"Standard message · object | Dynamic tool message · object"},"isRequired":true,"uniqueKey":"oneOf.0.messages","typeLabel":"(Standard message · object | Dynamic tool message · object)[]"},"model":{"type":"string","description":"Model ID","enum":["kimi-k3.1-pro","kimi-k3.1-pro-highspeed"],"default":"kimi-k3.1-pro","isRequired":true,"uniqueKey":"oneOf.0.model","typeLabel":"enum\u003cstring>"},"logprobs":{"type":"boolean","default":false,"description":"Whether to return log probabilities of the output tokens. If true, the log probability of each output token is returned in the logprobs field of the response message.","uniqueKey":"oneOf.0.logprobs","typeLabel":"boolean"},"top_logprobs":{"type":"integer","minimum":0,"maximum":20,"description":"An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true when this parameter is used.","uniqueKey":"oneOf.0.top_logprobs","typeLabel":"integer"},"prediction":{"type":"object","description":"Configuration for a Predicted Output, which can greatly improve response times when large parts of the model response are known ahead of time (for example, regenerating a file with only minor changes).","properties":{"type":{"type":"string","enum":["content"],"description":"The type of the predicted content. Currently only content is supported.","uniqueKey":"oneOf.0.prediction.type","typeLabel":"enum\u003cstring>"},"content":{"oneOf":[{"type":"string","description":"The static predicted output content that should be matched when generating the model response, such as the content of a text file being regenerated. Accepts a string or an array of content parts (text parts only).","uniqueKey":"oneOf.0.prediction.content.oneOf.0","typeLabel":"string"},{"type":"array","items":{"type":"object","uniqueKey":"oneOf.0.prediction.content.oneOf.1.items.[INDEX]","typeLabel":"object"},"description":"The static predicted output content that should be matched when generating the model response, such as the content of a text file being regenerated. Accepts a string or an array of content parts (text parts only).","uniqueKey":"oneOf.0.prediction.content.oneOf.1","typeLabel":"object[]"}],"uniqueKey":"oneOf.0.prediction.content","typeLabel":"string | object[]"}},"uniqueKey":"oneOf.0.prediction","typeLabel":"object"},"max_tokens":{"type":"integer","deprecated":true,"description":"Deprecated, please refer to max_completion_tokens","uniqueKey":"oneOf.0.max_tokens","typeLabel":"integer"},"max_completion_tokens":{"type":"integer","description":"The maximum number of tokens to generate for the chat completion. The default varies by model: for Kimi K3-series models (kimi-k3.1-pro, kimi-k3.1-pro-highspeed, kimi-k3) it defaults to 131072 and can be set up to 1048576. If the result reaches the maximum number of tokens without ending, the finish reason will be \"length\"; otherwise, it will be \"stop\". This refers to the length of tokens you expect us to return, not the total length of input plus output. If the sum of the input token count (`prompt_tokens`) and `max_completion_tokens` exceeds the model context window, the API automatically lowers the generation limit for the current request to fit the remaining context space and continues processing the request. The input token count itself must be less than the model context window size.","uniqueKey":"oneOf.0.max_completion_tokens","typeLabel":"integer"},"response_format":{"type":"object","description":"Controls the model output format. Default is {\"type\": \"text\"} for plain text output. Set to {\"type\": \"json_object\"} to enable JSON mode, ensuring output is a valid JSON object (you must guide the model to output JSON in the prompt). Set to {\"type\": \"json_schema\"} to enable Structured Output, constraining output to match a specified JSON Schema (recommended, requires the json_schema field). If you encounter schema validation issues, please submit feedback at walle GitHub Issues (https://github.com/MoonshotAI/walle/issues).","properties":{"type":{"type":"string","enum":["text","json_object","json_schema"],"description":"Output format type. text: default, plain text output; json_object: ensures output is a valid JSON object; json_schema: constrains output to match a specified JSON Schema (recommended, requires the json_schema field)","uniqueKey":"oneOf.0.response_format.type","typeLabel":"enum\u003cstring>"},"json_schema":{"type":"object","description":"Used when type is json_schema. Defines the JSON Schema that the output should conform to.","properties":{"name":{"type":"string","description":"Schema name for identification","isRequired":true,"uniqueKey":"oneOf.0.response_format.json_schema.name","typeLabel":"string"},"schema":{"type":"object","description":"The JSON Schema object defining the structure the output should conform to. Must conform to MFJS (Moonshot Flavored JSON Schema) specification. You can use the walle CLI tool to validate: go install github.com/moonshotai/walle/cmd/walle@latest \u0026\u0026 walle -schema 'your_schema' -level strict","additionalProperties":true,"isRequired":true,"uniqueKey":"oneOf.0.response_format.json_schema.schema","typeLabel":"object"},"strict":{"type":"boolean","default":true,"description":"Whether to strictly constrain output according to the schema. Defaults to true. When true, the schema must conform to the MFJS specification; non-conforming schemas will return errors or warnings. When false, only guarantees the output is a valid JSON object without enforcing internal structure.","uniqueKey":"oneOf.0.response_format.json_schema.strict","typeLabel":"boolean"}},"required":["name","schema"],"uniqueKey":"oneOf.0.response_format.json_schema","typeLabel":"object"}},"uniqueKey":"oneOf.0.response_format","typeLabel":"object"},"stop":{"oneOf":[{"type":"string","description":"Stop words, which will halt the output when a full match is found. The matched words themselves will not be output. A maximum of 5 strings is allowed, and each string must not exceed 32 bytes","uniqueKey":"oneOf.0.stop.oneOf.0","typeLabel":"string"},{"type":"array","items":{"type":"string","uniqueKey":"oneOf.0.stop.oneOf.1.items.[INDEX]","typeLabel":"string"},"description":"Stop words, which will halt the output when a full match is found. The matched words themselves will not be output. A maximum of 5 strings is allowed, and each string must not exceed 32 bytes","maxItems":5,"uniqueKey":"oneOf.0.stop.oneOf.1","typeLabel":"string[]"}],"uniqueKey":"oneOf.0.stop","typeLabel":"string | string[]"},"stream":{"type":"boolean","default":false,"description":"Whether to return the response in a streaming fashion. Default is false.","uniqueKey":"oneOf.0.stream","typeLabel":"boolean"},"stream_options":{"type":"object","description":"Options for streaming responses","properties":{"include_usage":{"type":"boolean","default":false,"description":"If set, an additional chunk will be streamed before the data: [DONE] message. The usage field on this chunk shows the token usage statistics for the entire request, and the choices field will always be an empty array. All other chunks will also include a usage field, but with a null value. NOTE: If the stream is interrupted, you may not receive the final usage chunk which contains the total token usage for the request","uniqueKey":"oneOf.0.stream_options.include_usage","typeLabel":"boolean"}},"uniqueKey":"oneOf.0.stream_options","typeLabel":"object"},"tools":{"type":"array","description":"A list of tools the model may call","items":{"type":"object","properties":{"type":{"type":"string","enum":["function"],"isRequired":true,"uniqueKey":"oneOf.0.tools.items.[INDEX].type","typeLabel":"enum\u003cstring>"},"function":{"type":"object","properties":{"name":{"type":"string","description":"Function name. Must follow the regex: ^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$","pattern":"^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$","isRequired":true,"uniqueKey":"oneOf.0.tools.items.[INDEX].function.name","typeLabel":"string"},"parameters":{"type":"object","description":"Function parameters as JSON Schema. Must conform to the [MFJS (Moonshot Flavored JSON Schema) specification](https://github.com/MoonshotAI/walle/blob/main/docs/mfjs-spec.md).","additionalProperties":true,"isRequired":true,"uniqueKey":"oneOf.0.tools.items.[INDEX].function.parameters","typeLabel":"object"},"description":{"type":"string","description":"Description of what the function does","uniqueKey":"oneOf.0.tools.items.[INDEX].function.description","typeLabel":"string"},"strict":{"type":"boolean","default":true,"description":"Whether to strictly constrain tool call arguments according to the parameters schema. Defaults to true. When false, only guarantees the output is a valid JSON object without enforcing internal structure.","uniqueKey":"oneOf.0.tools.items.[INDEX].function.strict","typeLabel":"boolean"}},"required":["name","parameters"],"isRequired":true,"uniqueKey":"oneOf.0.tools.items.[INDEX].function","typeLabel":"object"}},"required":["type","function"],"uniqueKey":"oneOf.0.tools.items.[INDEX]","typeLabel":"object"},"uniqueKey":"oneOf.0.tools","typeLabel":"object[]"},"prompt_cache_key":{"type":"string","default":null,"description":"Used to cache responses for similar requests to optimize cache hit rates. For Coding Agents, this is typically a session id or task id representing a single session; if the session is exited and later resumed, this value should remain the same. For Kimi Code Plan, this field is required to improve cache hit rates. For other agents involving multi-turn conversations, it is also recommended to implement this field","uniqueKey":"oneOf.0.prompt_cache_key","typeLabel":"string"},"prompt_cache_options":{"type":"object","description":"Context cache write options. When omitted, cache write is enabled by default (5m tier): the system automatically writes the request prefix to the 5m cache tier","properties":{"mode":{"type":"string","enum":["implicit"],"default":"implicit","description":"Cache write mode. Only implicit is supported: automatically writes the request prefix to the cache","uniqueKey":"oneOf.0.prompt_cache_options.mode","typeLabel":"enum\u003cstring>"},"ttl":{"type":"string","enum":["5m","1h"],"default":"5m","description":"Lifetime of the written cache. The 5m and 1h tiers are independent of each other. When a request with the same prefix hits the cache within its lifetime, the cache entry is refreshed with its original TTL","uniqueKey":"oneOf.0.prompt_cache_options.ttl","typeLabel":"enum\u003cstring>"}},"uniqueKey":"oneOf.0.prompt_cache_options","typeLabel":"object"},"safety_identifier":{"type":"string","description":"A stable identifier used to help detect users of your application that may be violating usage policies. The ID should be a string that uniquely identifies each user. It is recommended to hash the username or email address to avoid sending any identifying information","uniqueKey":"oneOf.0.safety_identifier","typeLabel":"string"},"tool_choice":{"oneOf":[{"type":"string","description":"Controls whether the model calls tools. `auto` (default): the model decides whether to call tools; `none`: no tool calls; `required`: force a tool call; or pass an object specifying a particular function to force that tool call.","enum":["auto","none","required"],"uniqueKey":"oneOf.0.tool_choice.oneOf.0","typeLabel":"enum\u003cstring>"},{"type":"object","description":"Controls whether the model calls tools. `auto` (default): the model decides whether to call tools; `none`: no tool calls; `required`: force a tool call; or pass an object specifying a particular function to force that tool call.","required":["type","function"],"properties":{"type":{"type":"string","enum":["function"],"isRequired":true,"uniqueKey":"oneOf.0.tool_choice.oneOf.1.type","typeLabel":"enum\u003cstring>"},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call","isRequired":true,"uniqueKey":"oneOf.0.tool_choice.oneOf.1.function.name","typeLabel":"string"}},"required":["name"],"isRequired":true,"uniqueKey":"oneOf.0.tool_choice.oneOf.1.function","typeLabel":"object"}},"uniqueKey":"oneOf.0.tool_choice.oneOf.1","typeLabel":"object"}],"uniqueKey":"oneOf.0.tool_choice","typeLabel":"enum\u003cstring> | object"},"reasoning_effort":{"type":"string","enum":["low","high","max"],"default":"max","description":"Kimi K3-series models always enable thinking with Preserved Thinking. Reasoning effort supports low, high, and max, with max as the default.","uniqueKey":"oneOf.0.reasoning_effort","typeLabel":"enum\u003cstring>"}},"uniqueKey":"oneOf.0","typeLabel":"kimi-k3.1-pro series · object"},{"type":"object","title":"kimi-k3","required":["model","messages"],"properties":{"messages":{"type":"array","description":"A list of conversation messages.","items":{"oneOf":[{"type":"object","title":"Standard message","description":"Supports standard conversation messages and system messages for dynamically loading tools.","required":["role","content"],"properties":{"role":{"type":"string","enum":["system","user","assistant","tool"],"example":"user","description":"The role of the message sender. Supports system, user, assistant, tool.","isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.role","typeLabel":"enum\u003cstring>"},"content":{"oneOf":[{"type":"string","description":"The content of the message. Can be a plain text string, or an array of objects with text/image_url/video_url types (for multimodal input)","example":"Hello","isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.0","typeLabel":"string"},{"type":"array","items":{"oneOf":[{"type":"object","title":"text","required":["type","text"],"properties":{"type":{"type":"string","enum":["text"],"isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.0.type","typeLabel":"enum\u003cstring>"},"text":{"type":"string","isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.0.text","typeLabel":"string"}},"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.0","typeLabel":"text · object"},{"type":"object","title":"image_url","required":["type","image_url"],"properties":{"type":{"type":"string","enum":["image_url"],"isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.1.type","typeLabel":"enum\u003cstring>"},"image_url":{"oneOf":[{"type":"object","required":["url"],"properties":{"url":{"type":"string","isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.1.image_url.oneOf.0.url","typeLabel":"string"}},"isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.1.image_url.oneOf.0","typeLabel":"object"},{"type":"string","isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.1.image_url.oneOf.1","typeLabel":"string"}],"isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.1.image_url","typeLabel":"object | string"}},"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.1","typeLabel":"image_url · object"},{"type":"object","title":"video_url","required":["type","video_url"],"properties":{"type":{"type":"string","enum":["video_url"],"isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.2.type","typeLabel":"enum\u003cstring>"},"video_url":{"oneOf":[{"type":"object","required":["url"],"properties":{"url":{"type":"string","isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.2.video_url.oneOf.0.url","typeLabel":"string"}},"isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.2.video_url.oneOf.0","typeLabel":"object"},{"type":"string","isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.2.video_url.oneOf.1","typeLabel":"string"}],"isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.2.video_url","typeLabel":"object | string"}},"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX].oneOf.2","typeLabel":"video_url · object"}],"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1.items.[INDEX]","typeLabel":"text · object | image_url · object | video_url · object"},"description":"The content of the message. Can be a plain text string, or an array of objects with text/image_url/video_url types (for multimodal input)","example":"Hello","isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content.oneOf.1","typeLabel":"(text · object | image_url · object | video_url · object)[]"}],"isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.content","typeLabel":"string | (text · object | image_url · object | video_url · object)[]"},"name":{"type":"string","default":null,"description":"Optional name for the message sender","uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.name","typeLabel":"string"},"partial":{"type":"boolean","default":false,"description":"Enable Partial Mode by setting this to true in the last assistant message","uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0.partial","typeLabel":"boolean"}},"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.0","typeLabel":"Standard message · object"},{"type":"object","title":"Dynamic tool message","description":"Supports standard conversation messages and system messages for dynamically loading tools.","required":["role","tools"],"properties":{"role":{"type":"string","enum":["system"],"description":"The role of a dynamic tool loading message. Always system.","isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.1.role","typeLabel":"enum\u003cstring>"},"tools":{"type":"array","description":"Tools available for the model to call from this message onward","items":{"type":"object","properties":{"type":{"type":"string","enum":["function"],"isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.1.tools.items.[INDEX].type","typeLabel":"enum\u003cstring>"},"function":{"type":"object","properties":{"name":{"type":"string","description":"Function name. Must follow the regex: ^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$","pattern":"^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$","isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.1.tools.items.[INDEX].function.name","typeLabel":"string"},"parameters":{"type":"object","description":"Function parameters as JSON Schema. Must conform to the [MFJS (Moonshot Flavored JSON Schema) specification](https://github.com/MoonshotAI/walle/blob/main/docs/mfjs-spec.md).","additionalProperties":true,"isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.1.tools.items.[INDEX].function.parameters","typeLabel":"object"},"description":{"type":"string","description":"Description of what the function does","uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.1.tools.items.[INDEX].function.description","typeLabel":"string"},"strict":{"type":"boolean","default":true,"description":"Whether to strictly constrain tool call arguments according to the parameters schema. Defaults to true. When false, only guarantees the output is a valid JSON object without enforcing internal structure.","uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.1.tools.items.[INDEX].function.strict","typeLabel":"boolean"}},"required":["name","parameters"],"isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.1.tools.items.[INDEX].function","typeLabel":"object"}},"required":["type","function"],"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.1.tools.items.[INDEX]","typeLabel":"object"},"isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.1.tools","typeLabel":"object[]"}},"additionalProperties":false,"uniqueKey":"oneOf.1.messages.items.[INDEX].oneOf.1","typeLabel":"Dynamic tool message · object"}],"uniqueKey":"oneOf.1.messages.items.[INDEX]","typeLabel":"Standard message · object | Dynamic tool message · object"},"isRequired":true,"uniqueKey":"oneOf.1.messages","typeLabel":"(Standard message · object | Dynamic tool message · object)[]"},"model":{"type":"string","description":"Model ID","enum":["kimi-k3"],"default":"kimi-k3","isRequired":true,"uniqueKey":"oneOf.1.model","typeLabel":"enum\u003cstring>"},"logprobs":{"type":"boolean","default":false,"description":"Whether to return log probabilities of the output tokens. If true, the log probability of each output token is returned in the logprobs field of the response message.","uniqueKey":"oneOf.1.logprobs","typeLabel":"boolean"},"top_logprobs":{"type":"integer","minimum":0,"maximum":20,"description":"An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true when this parameter is used.","uniqueKey":"oneOf.1.top_logprobs","typeLabel":"integer"},"prediction":{"type":"object","description":"Configuration for a Predicted Output, which can greatly improve response times when large parts of the model response are known ahead of time (for example, regenerating a file with only minor changes).","properties":{"type":{"type":"string","enum":["content"],"description":"The type of the predicted content. Currently only content is supported.","uniqueKey":"oneOf.1.prediction.type","typeLabel":"enum\u003cstring>"},"content":{"oneOf":[{"type":"string","description":"The static predicted output content that should be matched when generating the model response, such as the content of a text file being regenerated. Accepts a string or an array of content parts (text parts only).","uniqueKey":"oneOf.1.prediction.content.oneOf.0","typeLabel":"string"},{"type":"array","items":{"type":"object","uniqueKey":"oneOf.1.prediction.content.oneOf.1.items.[INDEX]","typeLabel":"object"},"description":"The static predicted output content that should be matched when generating the model response, such as the content of a text file being regenerated. Accepts a string or an array of content parts (text parts only).","uniqueKey":"oneOf.1.prediction.content.oneOf.1","typeLabel":"object[]"}],"uniqueKey":"oneOf.1.prediction.content","typeLabel":"string | object[]"}},"uniqueKey":"oneOf.1.prediction","typeLabel":"object"},"max_tokens":{"type":"integer","deprecated":true,"description":"Deprecated, please refer to max_completion_tokens","uniqueKey":"oneOf.1.max_tokens","typeLabel":"integer"},"max_completion_tokens":{"type":"integer","description":"The maximum number of tokens to generate for the chat completion. The default varies by model: for Kimi K3-series models (kimi-k3.1-pro, kimi-k3.1-pro-highspeed, kimi-k3) it defaults to 131072 and can be set up to 1048576. If the result reaches the maximum number of tokens without ending, the finish reason will be \"length\"; otherwise, it will be \"stop\". This refers to the length of tokens you expect us to return, not the total length of input plus output. If the sum of the input token count (`prompt_tokens`) and `max_completion_tokens` exceeds the model context window, the API automatically lowers the generation limit for the current request to fit the remaining context space and continues processing the request. The input token count itself must be less than the model context window size.","uniqueKey":"oneOf.1.max_completion_tokens","typeLabel":"integer"},"response_format":{"type":"object","description":"Controls the model output format. Default is {\"type\": \"text\"} for plain text output. Set to {\"type\": \"json_object\"} to enable JSON mode, ensuring output is a valid JSON object (you must guide the model to output JSON in the prompt). Set to {\"type\": \"json_schema\"} to enable Structured Output, constraining output to match a specified JSON Schema (recommended, requires the json_schema field). If you encounter schema validation issues, please submit feedback at walle GitHub Issues (https://github.com/MoonshotAI/walle/issues).","properties":{"type":{"type":"string","enum":["text","json_object","json_schema"],"description":"Output format type. text: default, plain text output; json_object: ensures output is a valid JSON object; json_schema: constrains output to match a specified JSON Schema (recommended, requires the json_schema field)","uniqueKey":"oneOf.1.response_format.type","typeLabel":"enum\u003cstring>"},"json_schema":{"type":"object","description":"Used when type is json_schema. Defines the JSON Schema that the output should conform to.","properties":{"name":{"type":"string","description":"Schema name for identification","isRequired":true,"uniqueKey":"oneOf.1.response_format.json_schema.name","typeLabel":"string"},"schema":{"type":"object","description":"The JSON Schema object defining the structure the output should conform to. Must conform to MFJS (Moonshot Flavored JSON Schema) specification. You can use the walle CLI tool to validate: go install github.com/moonshotai/walle/cmd/walle@latest \u0026\u0026 walle -schema 'your_schema' -level strict","additionalProperties":true,"isRequired":true,"uniqueKey":"oneOf.1.response_format.json_schema.schema","typeLabel":"object"},"strict":{"type":"boolean","default":true,"description":"Whether to strictly constrain output according to the schema. Defaults to true. When true, the schema must conform to the MFJS specification; non-conforming schemas will return errors or warnings. When false, only guarantees the output is a valid JSON object without enforcing internal structure.","uniqueKey":"oneOf.1.response_format.json_schema.strict","typeLabel":"boolean"}},"required":["name","schema"],"uniqueKey":"oneOf.1.response_format.json_schema","typeLabel":"object"}},"uniqueKey":"oneOf.1.response_format","typeLabel":"object"},"stop":{"oneOf":[{"type":"string","description":"Stop words, which will halt the output when a full match is found. The matched words themselves will not be output. A maximum of 5 strings is allowed, and each string must not exceed 32 bytes","uniqueKey":"oneOf.1.stop.oneOf.0","typeLabel":"string"},{"type":"array","items":{"type":"string","uniqueKey":"oneOf.1.stop.oneOf.1.items.[INDEX]","typeLabel":"string"},"description":"Stop words, which will halt the output when a full match is found. The matched words themselves will not be output. A maximum of 5 strings is allowed, and each string must not exceed 32 bytes","maxItems":5,"uniqueKey":"oneOf.1.stop.oneOf.1","typeLabel":"string[]"}],"uniqueKey":"oneOf.1.stop","typeLabel":"string | string[]"},"stream":{"type":"boolean","default":false,"description":"Whether to return the response in a streaming fashion. Default is false.","uniqueKey":"oneOf.1.stream","typeLabel":"boolean"},"stream_options":{"type":"object","description":"Options for streaming responses","properties":{"include_usage":{"type":"boolean","default":false,"description":"If set, an additional chunk will be streamed before the data: [DONE] message. The usage field on this chunk shows the token usage statistics for the entire request, and the choices field will always be an empty array. All other chunks will also include a usage field, but with a null value. NOTE: If the stream is interrupted, you may not receive the final usage chunk which contains the total token usage for the request","uniqueKey":"oneOf.1.stream_options.include_usage","typeLabel":"boolean"}},"uniqueKey":"oneOf.1.stream_options","typeLabel":"object"},"tools":{"type":"array","description":"A list of tools the model may call","items":{"type":"object","properties":{"type":{"type":"string","enum":["function"],"isRequired":true,"uniqueKey":"oneOf.1.tools.items.[INDEX].type","typeLabel":"enum\u003cstring>"},"function":{"type":"object","properties":{"name":{"type":"string","description":"Function name. Must follow the regex: ^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$","pattern":"^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$","isRequired":true,"uniqueKey":"oneOf.1.tools.items.[INDEX].function.name","typeLabel":"string"},"parameters":{"type":"object","description":"Function parameters as JSON Schema. Must conform to the [MFJS (Moonshot Flavored JSON Schema) specification](https://github.com/MoonshotAI/walle/blob/main/docs/mfjs-spec.md).","additionalProperties":true,"isRequired":true,"uniqueKey":"oneOf.1.tools.items.[INDEX].function.parameters","typeLabel":"object"},"description":{"type":"string","description":"Description of what the function does","uniqueKey":"oneOf.1.tools.items.[INDEX].function.description","typeLabel":"string"},"strict":{"type":"boolean","default":true,"description":"Whether to strictly constrain tool call arguments according to the parameters schema. Defaults to true. When false, only guarantees the output is a valid JSON object without enforcing internal structure.","uniqueKey":"oneOf.1.tools.items.[INDEX].function.strict","typeLabel":"boolean"}},"required":["name","parameters"],"isRequired":true,"uniqueKey":"oneOf.1.tools.items.[INDEX].function","typeLabel":"object"}},"required":["type","function"],"uniqueKey":"oneOf.1.tools.items.[INDEX]","typeLabel":"object"},"uniqueKey":"oneOf.1.tools","typeLabel":"object[]"},"prompt_cache_key":{"type":"string","default":null,"description":"Used to cache responses for similar requests to optimize cache hit rates. For Coding Agents, this is typically a session id or task id representing a single session; if the session is exited and later resumed, this value should remain the same. For Kimi Code Plan, this field is required to improve cache hit rates. For other agents involving multi-turn conversations, it is also recommended to implement this field","uniqueKey":"oneOf.1.prompt_cache_key","typeLabel":"string"},"prompt_cache_options":{"type":"object","description":"Context cache write options. When omitted, cache write is enabled by default (5m tier): the system automatically writes the request prefix to the 5m cache tier","properties":{"mode":{"type":"string","enum":["implicit"],"default":"implicit","description":"Cache write mode. Only implicit is supported: automatically writes the request prefix to the cache","uniqueKey":"oneOf.1.prompt_cache_options.mode","typeLabel":"enum\u003cstring>"},"ttl":{"type":"string","enum":["5m","1h"],"default":"5m","description":"Lifetime of the written cache. The 5m and 1h tiers are independent of each other. When a request with the same prefix hits the cache within its lifetime, the cache entry is refreshed with its original TTL","uniqueKey":"oneOf.1.prompt_cache_options.ttl","typeLabel":"enum\u003cstring>"}},"uniqueKey":"oneOf.1.prompt_cache_options","typeLabel":"object"},"safety_identifier":{"type":"string","description":"A stable identifier used to help detect users of your application that may be violating usage policies. The ID should be a string that uniquely identifies each user. It is recommended to hash the username or email address to avoid sending any identifying information","uniqueKey":"oneOf.1.safety_identifier","typeLabel":"string"},"tool_choice":{"oneOf":[{"type":"string","description":"Controls whether the model calls tools. `auto` (default): the model decides whether to call tools; `none`: no tool calls; `required`: force a tool call; or pass an object specifying a particular function to force that tool call.","enum":["auto","none","required"],"uniqueKey":"oneOf.1.tool_choice.oneOf.0","typeLabel":"enum\u003cstring>"},{"type":"object","description":"Controls whether the model calls tools. `auto` (default): the model decides whether to call tools; `none`: no tool calls; `required`: force a tool call; or pass an object specifying a particular function to force that tool call.","required":["type","function"],"properties":{"type":{"type":"string","enum":["function"],"isRequired":true,"uniqueKey":"oneOf.1.tool_choice.oneOf.1.type","typeLabel":"enum\u003cstring>"},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call","isRequired":true,"uniqueKey":"oneOf.1.tool_choice.oneOf.1.function.name","typeLabel":"string"}},"required":["name"],"isRequired":true,"uniqueKey":"oneOf.1.tool_choice.oneOf.1.function","typeLabel":"object"}},"uniqueKey":"oneOf.1.tool_choice.oneOf.1","typeLabel":"object"}],"uniqueKey":"oneOf.1.tool_choice","typeLabel":"enum\u003cstring> | object"},"reasoning_effort":{"type":"string","enum":["low","high","max"],"default":"max","description":"Kimi K3-series models always enable thinking with Preserved Thinking. Reasoning effort supports low, high, and max, with max as the default.","uniqueKey":"oneOf.1.reasoning_effort","typeLabel":"enum\u003cstring>"}},"uniqueKey":"oneOf.1","typeLabel":"kimi-k3 · object"},{"type":"object","title":"kimi-k2.7-code","required":["model","messages"],"properties":{"messages":{"type":"array","description":"A list of messages in the conversation so far. Each element has the format {\"role\": \"user\", \"content\": \"Hello\"}. role supports system, user, assistant, or tool. content must not be empty. The content field can be a string or an array[object] (for multimodal input).","items":{"type":"object","properties":{"role":{"type":"string","enum":["system","user","assistant","tool"],"example":"user","description":"The role of the message sender. Supports system, user, assistant, tool.","isRequired":true,"uniqueKey":"oneOf.2.messages.items.[INDEX].role","typeLabel":"enum\u003cstring>"},"content":{"oneOf":[{"type":"string","description":"The content of the message. Can be a plain text string, or an array of objects with text/image_url/video_url types (for multimodal input)","example":"Hello","isRequired":true,"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.0","typeLabel":"string"},{"type":"array","items":{"oneOf":[{"type":"object","title":"text","required":["type","text"],"properties":{"type":{"type":"string","enum":["text"],"isRequired":true,"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.0.type","typeLabel":"enum\u003cstring>"},"text":{"type":"string","isRequired":true,"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.0.text","typeLabel":"string"}},"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.0","typeLabel":"text · object"},{"type":"object","title":"image_url","required":["type","image_url"],"properties":{"type":{"type":"string","enum":["image_url"],"isRequired":true,"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.1.type","typeLabel":"enum\u003cstring>"},"image_url":{"oneOf":[{"type":"object","required":["url"],"properties":{"url":{"type":"string","isRequired":true,"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.1.image_url.oneOf.0.url","typeLabel":"string"}},"isRequired":true,"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.1.image_url.oneOf.0","typeLabel":"object"},{"type":"string","isRequired":true,"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.1.image_url.oneOf.1","typeLabel":"string"}],"isRequired":true,"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.1.image_url","typeLabel":"object | string"}},"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.1","typeLabel":"image_url · object"},{"type":"object","title":"video_url","required":["type","video_url"],"properties":{"type":{"type":"string","enum":["video_url"],"isRequired":true,"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.2.type","typeLabel":"enum\u003cstring>"},"video_url":{"oneOf":[{"type":"object","required":["url"],"properties":{"url":{"type":"string","isRequired":true,"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.2.video_url.oneOf.0.url","typeLabel":"string"}},"isRequired":true,"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.2.video_url.oneOf.0","typeLabel":"object"},{"type":"string","isRequired":true,"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.2.video_url.oneOf.1","typeLabel":"string"}],"isRequired":true,"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.2.video_url","typeLabel":"object | string"}},"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.2","typeLabel":"video_url · object"}],"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1.items.[INDEX]","typeLabel":"text · object | image_url · object | video_url · object"},"description":"The content of the message. Can be a plain text string, or an array of objects with text/image_url/video_url types (for multimodal input)","example":"Hello","isRequired":true,"uniqueKey":"oneOf.2.messages.items.[INDEX].content.oneOf.1","typeLabel":"(text · object | image_url · object | video_url · object)[]"}],"isRequired":true,"uniqueKey":"oneOf.2.messages.items.[INDEX].content","typeLabel":"string | (text · object | image_url · object | video_url · object)[]"},"name":{"type":"string","default":null,"description":"Optional name for the message sender","uniqueKey":"oneOf.2.messages.items.[INDEX].name","typeLabel":"string"},"partial":{"type":"boolean","default":false,"description":"Enable Partial Mode by setting this to true in the last assistant message","uniqueKey":"oneOf.2.messages.items.[INDEX].partial","typeLabel":"boolean"}},"required":["role","content"],"uniqueKey":"oneOf.2.messages.items.[INDEX]","typeLabel":"object"},"isRequired":true,"uniqueKey":"oneOf.2.messages","typeLabel":"object[]"},"model":{"type":"string","description":"Model ID. Either `kimi-k2.7-code` or its high-speed variant `kimi-k2.7-code-highspeed`; the two are the same model with identical parameters, while the high-speed variant outputs at approximately 180 Tokens/s (up to 260 Tokens/s in short-context scenarios).","enum":["kimi-k2.7-code","kimi-k2.7-code-highspeed"],"default":"kimi-k2.7-code","isRequired":true,"uniqueKey":"oneOf.2.model","typeLabel":"enum\u003cstring>"},"logprobs":{"type":"boolean","default":false,"description":"Whether to return log probabilities of the output tokens. If true, the log probability of each output token is returned in the logprobs field of the response message.","uniqueKey":"oneOf.2.logprobs","typeLabel":"boolean"},"top_logprobs":{"type":"integer","minimum":0,"maximum":20,"description":"An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true when this parameter is used.","uniqueKey":"oneOf.2.top_logprobs","typeLabel":"integer"},"prediction":{"type":"object","description":"Configuration for a Predicted Output, which can greatly improve response times when large parts of the model response are known ahead of time (for example, regenerating a file with only minor changes).","properties":{"type":{"type":"string","enum":["content"],"description":"The type of the predicted content. Currently only content is supported.","uniqueKey":"oneOf.2.prediction.type","typeLabel":"enum\u003cstring>"},"content":{"oneOf":[{"type":"string","description":"The static predicted output content that should be matched when generating the model response, such as the content of a text file being regenerated. Accepts a string or an array of content parts (text parts only).","uniqueKey":"oneOf.2.prediction.content.oneOf.0","typeLabel":"string"},{"type":"array","items":{"type":"object","uniqueKey":"oneOf.2.prediction.content.oneOf.1.items.[INDEX]","typeLabel":"object"},"description":"The static predicted output content that should be matched when generating the model response, such as the content of a text file being regenerated. Accepts a string or an array of content parts (text parts only).","uniqueKey":"oneOf.2.prediction.content.oneOf.1","typeLabel":"object[]"}],"uniqueKey":"oneOf.2.prediction.content","typeLabel":"string | object[]"}},"uniqueKey":"oneOf.2.prediction","typeLabel":"object"},"max_tokens":{"type":"integer","deprecated":true,"description":"Deprecated, please refer to max_completion_tokens","uniqueKey":"oneOf.2.max_tokens","typeLabel":"integer"},"max_completion_tokens":{"type":"integer","description":"The maximum number of tokens to generate for the chat completion. The default varies by model: for Kimi K3-series models (kimi-k3.1-pro, kimi-k3.1-pro-highspeed, kimi-k3) it defaults to 131072 and can be set up to 1048576. If the result reaches the maximum number of tokens without ending, the finish reason will be \"length\"; otherwise, it will be \"stop\". This refers to the length of tokens you expect us to return, not the total length of input plus output. If the sum of the input token count (`prompt_tokens`) and `max_completion_tokens` exceeds the model context window, the API automatically lowers the generation limit for the current request to fit the remaining context space and continues processing the request. The input token count itself must be less than the model context window size.","uniqueKey":"oneOf.2.max_completion_tokens","typeLabel":"integer"},"response_format":{"type":"object","description":"Controls the model output format. Default is {\"type\": \"text\"} for plain text output. Set to {\"type\": \"json_object\"} to enable JSON mode, ensuring output is a valid JSON object (you must guide the model to output JSON in the prompt). Set to {\"type\": \"json_schema\"} to enable Structured Output, constraining output to match a specified JSON Schema (recommended, requires the json_schema field). If you encounter schema validation issues, please submit feedback at walle GitHub Issues (https://github.com/MoonshotAI/walle/issues).","properties":{"type":{"type":"string","enum":["text","json_object","json_schema"],"description":"Output format type. text: default, plain text output; json_object: ensures output is a valid JSON object; json_schema: constrains output to match a specified JSON Schema (recommended, requires the json_schema field)","uniqueKey":"oneOf.2.response_format.type","typeLabel":"enum\u003cstring>"},"json_schema":{"type":"object","description":"Used when type is json_schema. Defines the JSON Schema that the output should conform to.","properties":{"name":{"type":"string","description":"Schema name for identification","isRequired":true,"uniqueKey":"oneOf.2.response_format.json_schema.name","typeLabel":"string"},"schema":{"type":"object","description":"The JSON Schema object defining the structure the output should conform to. Must conform to MFJS (Moonshot Flavored JSON Schema) specification. You can use the walle CLI tool to validate: go install github.com/moonshotai/walle/cmd/walle@latest \u0026\u0026 walle -schema 'your_schema' -level strict","additionalProperties":true,"isRequired":true,"uniqueKey":"oneOf.2.response_format.json_schema.schema","typeLabel":"object"},"strict":{"type":"boolean","default":true,"description":"Whether to strictly constrain output according to the schema. Defaults to true. When true, the schema must conform to the MFJS specification; non-conforming schemas will return errors or warnings. When false, only guarantees the output is a valid JSON object without enforcing internal structure.","uniqueKey":"oneOf.2.response_format.json_schema.strict","typeLabel":"boolean"}},"required":["name","schema"],"uniqueKey":"oneOf.2.response_format.json_schema","typeLabel":"object"}},"uniqueKey":"oneOf.2.response_format","typeLabel":"object"},"stop":{"oneOf":[{"type":"string","description":"Stop words, which will halt the output when a full match is found. The matched words themselves will not be output. A maximum of 5 strings is allowed, and each string must not exceed 32 bytes","uniqueKey":"oneOf.2.stop.oneOf.0","typeLabel":"string"},{"type":"array","items":{"type":"string","uniqueKey":"oneOf.2.stop.oneOf.1.items.[INDEX]","typeLabel":"string"},"description":"Stop words, which will halt the output when a full match is found. The matched words themselves will not be output. A maximum of 5 strings is allowed, and each string must not exceed 32 bytes","maxItems":5,"uniqueKey":"oneOf.2.stop.oneOf.1","typeLabel":"string[]"}],"uniqueKey":"oneOf.2.stop","typeLabel":"string | string[]"},"stream":{"type":"boolean","default":false,"description":"Whether to return the response in a streaming fashion. Default is false.","uniqueKey":"oneOf.2.stream","typeLabel":"boolean"},"stream_options":{"type":"object","description":"Options for streaming responses","properties":{"include_usage":{"type":"boolean","default":false,"description":"If set, an additional chunk will be streamed before the data: [DONE] message. The usage field on this chunk shows the token usage statistics for the entire request, and the choices field will always be an empty array. All other chunks will also include a usage field, but with a null value. NOTE: If the stream is interrupted, you may not receive the final usage chunk which contains the total token usage for the request","uniqueKey":"oneOf.2.stream_options.include_usage","typeLabel":"boolean"}},"uniqueKey":"oneOf.2.stream_options","typeLabel":"object"},"tools":{"type":"array","description":"A list of tools the model may call","items":{"type":"object","properties":{"type":{"type":"string","enum":["function"],"isRequired":true,"uniqueKey":"oneOf.2.tools.items.[INDEX].type","typeLabel":"enum\u003cstring>"},"function":{"type":"object","properties":{"name":{"type":"string","description":"Function name. Must follow the regex: ^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$","pattern":"^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$","isRequired":true,"uniqueKey":"oneOf.2.tools.items.[INDEX].function.name","typeLabel":"string"},"parameters":{"type":"object","description":"Function parameters as JSON Schema. Must conform to the [MFJS (Moonshot Flavored JSON Schema) specification](https://github.com/MoonshotAI/walle/blob/main/docs/mfjs-spec.md).","additionalProperties":true,"isRequired":true,"uniqueKey":"oneOf.2.tools.items.[INDEX].function.parameters","typeLabel":"object"},"description":{"type":"string","description":"Description of what the function does","uniqueKey":"oneOf.2.tools.items.[INDEX].function.description","typeLabel":"string"},"strict":{"type":"boolean","default":true,"description":"Whether to strictly constrain tool call arguments according to the parameters schema. Defaults to true. When false, only guarantees the output is a valid JSON object without enforcing internal structure.","uniqueKey":"oneOf.2.tools.items.[INDEX].function.strict","typeLabel":"boolean"}},"required":["name","parameters"],"isRequired":true,"uniqueKey":"oneOf.2.tools.items.[INDEX].function","typeLabel":"object"}},"required":["type","function"],"uniqueKey":"oneOf.2.tools.items.[INDEX]","typeLabel":"object"},"uniqueKey":"oneOf.2.tools","typeLabel":"object[]"},"prompt_cache_key":{"type":"string","default":null,"description":"Used to cache responses for similar requests to optimize cache hit rates. For Coding Agents, this is typically a session id or task id representing a single session; if the session is exited and later resumed, this value should remain the same. For Kimi Code Plan, this field is required to improve cache hit rates. For other agents involving multi-turn conversations, it is also recommended to implement this field","uniqueKey":"oneOf.2.prompt_cache_key","typeLabel":"string"},"prompt_cache_options":{"type":"object","description":"Context cache write options. When omitted, cache write is enabled by default (5m tier): the system automatically writes the request prefix to the 5m cache tier","properties":{"mode":{"type":"string","enum":["implicit"],"default":"implicit","description":"Cache write mode. Only implicit is supported: automatically writes the request prefix to the cache","uniqueKey":"oneOf.2.prompt_cache_options.mode","typeLabel":"enum\u003cstring>"},"ttl":{"type":"string","enum":["5m","1h"],"default":"5m","description":"Lifetime of the written cache. The 5m and 1h tiers are independent of each other. When a request with the same prefix hits the cache within its lifetime, the cache entry is refreshed with its original TTL","uniqueKey":"oneOf.2.prompt_cache_options.ttl","typeLabel":"enum\u003cstring>"}},"uniqueKey":"oneOf.2.prompt_cache_options","typeLabel":"object"},"safety_identifier":{"type":"string","description":"A stable identifier used to help detect users of your application that may be violating usage policies. The ID should be a string that uniquely identifies each user. It is recommended to hash the username or email address to avoid sending any identifying information","uniqueKey":"oneOf.2.safety_identifier","typeLabel":"string"},"tool_choice":{"oneOf":[{"type":"string","description":"Controls whether the model calls tools. `auto` (default): the model decides whether to call tools; `none`: no tool calls; `required`: force a tool call; or pass an object specifying a particular function to force that tool call.","enum":["auto","none","required"],"uniqueKey":"oneOf.2.tool_choice.oneOf.0","typeLabel":"enum\u003cstring>"},{"type":"object","description":"Controls whether the model calls tools. `auto` (default): the model decides whether to call tools; `none`: no tool calls; `required`: force a tool call; or pass an object specifying a particular function to force that tool call.","required":["type","function"],"properties":{"type":{"type":"string","enum":["function"],"isRequired":true,"uniqueKey":"oneOf.2.tool_choice.oneOf.1.type","typeLabel":"enum\u003cstring>"},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call","isRequired":true,"uniqueKey":"oneOf.2.tool_choice.oneOf.1.function.name","typeLabel":"string"}},"required":["name"],"isRequired":true,"uniqueKey":"oneOf.2.tool_choice.oneOf.1.function","typeLabel":"object"}},"uniqueKey":"oneOf.2.tool_choice.oneOf.1","typeLabel":"object"}],"uniqueKey":"oneOf.2.tool_choice","typeLabel":"enum\u003cstring> | object"},"thinking":{"type":"object","description":"Controls thinking for the kimi-k2.7-code model, and whether to fully preserve reasoning_content across multi-turn conversations. Optional parameter. Default value is {\"type\": \"enabled\", \"keep\": \"all\"}.\n\nDifferences from kimi-k2.6:\n- `type` only accepts `\"enabled\"`. Unlike kimi-k2.6, `\"disabled\"` is NOT supported — passing it returns an error. Thinking is always on for this model.\n- `keep` only accepts the valid value `\"all\"`; omitting it or passing `\"all\"` is treated as `\"all\"` on the server, while any other invalid value returns an error. Preserved Thinking is therefore always enabled for this model.","properties":{"type":{"type":"string","enum":["enabled"],"description":"Enable thinking capability. For kimi-k2.7-code, only `\"enabled\"` is accepted; passing `\"disabled\"` returns an error. This differs from kimi-k2.6, which also supports `\"disabled\"`.","isRequired":true,"uniqueKey":"oneOf.2.thinking.type","typeLabel":"enum\u003cstring>"},"keep":{"oneOf":[{"type":"string","enum":["all",null],"description":"Controls whether reasoning_content from previous turns is preserved across a multi-turn conversation, i.e. whether to enable Preserved Thinking.\n\n- For kimi-k2.7-code this parameter only accepts the valid value `\"all\"`: passing `\"all\"`, passing `null`, or omitting it all behave identically and are treated as `\"all\"` on the server — reasoning_content from historical turns is always preserved; passing any other invalid value returns an error. This differs from kimi-k2.6, whose default is `null` (historical thinking NOT preserved unless you explicitly set `\"all\"`).\n- Because Preserved Thinking is always on, keep the reasoning_content from every historical assistant message in messages as-is.\n- Note: This parameter only affects reasoning_content from historical turns; it does not change whether the model produces/outputs thinking within the current turn (that is controlled by `type`). For best practices, see [Preserved Thinking](/guide/use-thinking-models#preserved-thinking).","uniqueKey":"oneOf.2.thinking.keep.oneOf.0","typeLabel":"enum\u003cstring>"},{"type":"null","enum":["all",null],"description":"Controls whether reasoning_content from previous turns is preserved across a multi-turn conversation, i.e. whether to enable Preserved Thinking.\n\n- For kimi-k2.7-code this parameter only accepts the valid value `\"all\"`: passing `\"all\"`, passing `null`, or omitting it all behave identically and are treated as `\"all\"` on the server — reasoning_content from historical turns is always preserved; passing any other invalid value returns an error. This differs from kimi-k2.6, whose default is `null` (historical thinking NOT preserved unless you explicitly set `\"all\"`).\n- Because Preserved Thinking is always on, keep the reasoning_content from every historical assistant message in messages as-is.\n- Note: This parameter only affects reasoning_content from historical turns; it does not change whether the model produces/outputs thinking within the current turn (that is controlled by `type`). For best practices, see [Preserved Thinking](/guide/use-thinking-models#preserved-thinking).","uniqueKey":"oneOf.2.thinking.keep.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.2.thinking.keep","typeLabel":"enum\u003cstring> | null"}},"required":["type"],"additionalProperties":false,"uniqueKey":"oneOf.2.thinking","typeLabel":"object"}},"uniqueKey":"oneOf.2","typeLabel":"kimi-k2.7-code · object"},{"type":"object","title":"kimi-k2.6","required":["model","messages"],"properties":{"messages":{"type":"array","description":"A list of messages in the conversation so far. Each element has the format {\"role\": \"user\", \"content\": \"Hello\"}. role supports system, user, assistant, or tool. content must not be empty. The content field can be a string or an array[object] (for multimodal input).","items":{"type":"object","properties":{"role":{"type":"string","enum":["system","user","assistant","tool"],"example":"user","description":"The role of the message sender. Supports system, user, assistant, tool.","isRequired":true,"uniqueKey":"oneOf.3.messages.items.[INDEX].role","typeLabel":"enum\u003cstring>"},"content":{"oneOf":[{"type":"string","description":"The content of the message. Can be a plain text string, or an array of objects with text/image_url/video_url types (for multimodal input)","example":"Hello","isRequired":true,"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.0","typeLabel":"string"},{"type":"array","items":{"oneOf":[{"type":"object","title":"text","required":["type","text"],"properties":{"type":{"type":"string","enum":["text"],"isRequired":true,"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.0.type","typeLabel":"enum\u003cstring>"},"text":{"type":"string","isRequired":true,"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.0.text","typeLabel":"string"}},"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.0","typeLabel":"text · object"},{"type":"object","title":"image_url","required":["type","image_url"],"properties":{"type":{"type":"string","enum":["image_url"],"isRequired":true,"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.1.type","typeLabel":"enum\u003cstring>"},"image_url":{"oneOf":[{"type":"object","required":["url"],"properties":{"url":{"type":"string","isRequired":true,"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.1.image_url.oneOf.0.url","typeLabel":"string"}},"isRequired":true,"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.1.image_url.oneOf.0","typeLabel":"object"},{"type":"string","isRequired":true,"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.1.image_url.oneOf.1","typeLabel":"string"}],"isRequired":true,"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.1.image_url","typeLabel":"object | string"}},"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.1","typeLabel":"image_url · object"},{"type":"object","title":"video_url","required":["type","video_url"],"properties":{"type":{"type":"string","enum":["video_url"],"isRequired":true,"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.2.type","typeLabel":"enum\u003cstring>"},"video_url":{"oneOf":[{"type":"object","required":["url"],"properties":{"url":{"type":"string","isRequired":true,"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.2.video_url.oneOf.0.url","typeLabel":"string"}},"isRequired":true,"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.2.video_url.oneOf.0","typeLabel":"object"},{"type":"string","isRequired":true,"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.2.video_url.oneOf.1","typeLabel":"string"}],"isRequired":true,"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.2.video_url","typeLabel":"object | string"}},"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1.items.[INDEX].oneOf.2","typeLabel":"video_url · object"}],"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1.items.[INDEX]","typeLabel":"text · object | image_url · object | video_url · object"},"description":"The content of the message. Can be a plain text string, or an array of objects with text/image_url/video_url types (for multimodal input)","example":"Hello","isRequired":true,"uniqueKey":"oneOf.3.messages.items.[INDEX].content.oneOf.1","typeLabel":"(text · object | image_url · object | video_url · object)[]"}],"isRequired":true,"uniqueKey":"oneOf.3.messages.items.[INDEX].content","typeLabel":"string | (text · object | image_url · object | video_url · object)[]"},"name":{"type":"string","default":null,"description":"Optional name for the message sender","uniqueKey":"oneOf.3.messages.items.[INDEX].name","typeLabel":"string"},"partial":{"type":"boolean","default":false,"description":"Enable Partial Mode by setting this to true in the last assistant message","uniqueKey":"oneOf.3.messages.items.[INDEX].partial","typeLabel":"boolean"}},"required":["role","content"],"uniqueKey":"oneOf.3.messages.items.[INDEX]","typeLabel":"object"},"isRequired":true,"uniqueKey":"oneOf.3.messages","typeLabel":"object[]"},"model":{"type":"string","description":"Model ID","enum":["kimi-k2.6"],"default":"kimi-k2.6","isRequired":true,"uniqueKey":"oneOf.3.model","typeLabel":"enum\u003cstring>"},"logprobs":{"type":"boolean","default":false,"description":"Whether to return log probabilities of the output tokens. If true, the log probability of each output token is returned in the logprobs field of the response message.","uniqueKey":"oneOf.3.logprobs","typeLabel":"boolean"},"top_logprobs":{"type":"integer","minimum":0,"maximum":20,"description":"An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true when this parameter is used.","uniqueKey":"oneOf.3.top_logprobs","typeLabel":"integer"},"prediction":{"type":"object","description":"Configuration for a Predicted Output, which can greatly improve response times when large parts of the model response are known ahead of time (for example, regenerating a file with only minor changes).","properties":{"type":{"type":"string","enum":["content"],"description":"The type of the predicted content. Currently only content is supported.","uniqueKey":"oneOf.3.prediction.type","typeLabel":"enum\u003cstring>"},"content":{"oneOf":[{"type":"string","description":"The static predicted output content that should be matched when generating the model response, such as the content of a text file being regenerated. Accepts a string or an array of content parts (text parts only).","uniqueKey":"oneOf.3.prediction.content.oneOf.0","typeLabel":"string"},{"type":"array","items":{"type":"object","uniqueKey":"oneOf.3.prediction.content.oneOf.1.items.[INDEX]","typeLabel":"object"},"description":"The static predicted output content that should be matched when generating the model response, such as the content of a text file being regenerated. Accepts a string or an array of content parts (text parts only).","uniqueKey":"oneOf.3.prediction.content.oneOf.1","typeLabel":"object[]"}],"uniqueKey":"oneOf.3.prediction.content","typeLabel":"string | object[]"}},"uniqueKey":"oneOf.3.prediction","typeLabel":"object"},"max_tokens":{"type":"integer","deprecated":true,"description":"Deprecated, please refer to max_completion_tokens","uniqueKey":"oneOf.3.max_tokens","typeLabel":"integer"},"max_completion_tokens":{"type":"integer","description":"The maximum number of tokens to generate for the chat completion. The default varies by model: for Kimi K3-series models (kimi-k3.1-pro, kimi-k3.1-pro-highspeed, kimi-k3) it defaults to 131072 and can be set up to 1048576. If the result reaches the maximum number of tokens without ending, the finish reason will be \"length\"; otherwise, it will be \"stop\". This refers to the length of tokens you expect us to return, not the total length of input plus output. If the sum of the input token count (`prompt_tokens`) and `max_completion_tokens` exceeds the model context window, the API automatically lowers the generation limit for the current request to fit the remaining context space and continues processing the request. The input token count itself must be less than the model context window size.","uniqueKey":"oneOf.3.max_completion_tokens","typeLabel":"integer"},"response_format":{"type":"object","description":"Controls the model output format. Default is {\"type\": \"text\"} for plain text output. Set to {\"type\": \"json_object\"} to enable JSON mode, ensuring output is a valid JSON object (you must guide the model to output JSON in the prompt). Set to {\"type\": \"json_schema\"} to enable Structured Output, constraining output to match a specified JSON Schema (recommended, requires the json_schema field). If you encounter schema validation issues, please submit feedback at walle GitHub Issues (https://github.com/MoonshotAI/walle/issues).","properties":{"type":{"type":"string","enum":["text","json_object","json_schema"],"description":"Output format type. text: default, plain text output; json_object: ensures output is a valid JSON object; json_schema: constrains output to match a specified JSON Schema (recommended, requires the json_schema field)","uniqueKey":"oneOf.3.response_format.type","typeLabel":"enum\u003cstring>"},"json_schema":{"type":"object","description":"Used when type is json_schema. Defines the JSON Schema that the output should conform to.","properties":{"name":{"type":"string","description":"Schema name for identification","isRequired":true,"uniqueKey":"oneOf.3.response_format.json_schema.name","typeLabel":"string"},"schema":{"type":"object","description":"The JSON Schema object defining the structure the output should conform to. Must conform to MFJS (Moonshot Flavored JSON Schema) specification. You can use the walle CLI tool to validate: go install github.com/moonshotai/walle/cmd/walle@latest \u0026\u0026 walle -schema 'your_schema' -level strict","additionalProperties":true,"isRequired":true,"uniqueKey":"oneOf.3.response_format.json_schema.schema","typeLabel":"object"},"strict":{"type":"boolean","default":true,"description":"Whether to strictly constrain output according to the schema. Defaults to true. When true, the schema must conform to the MFJS specification; non-conforming schemas will return errors or warnings. When false, only guarantees the output is a valid JSON object without enforcing internal structure.","uniqueKey":"oneOf.3.response_format.json_schema.strict","typeLabel":"boolean"}},"required":["name","schema"],"uniqueKey":"oneOf.3.response_format.json_schema","typeLabel":"object"}},"uniqueKey":"oneOf.3.response_format","typeLabel":"object"},"stop":{"oneOf":[{"type":"string","description":"Stop words, which will halt the output when a full match is found. The matched words themselves will not be output. A maximum of 5 strings is allowed, and each string must not exceed 32 bytes","uniqueKey":"oneOf.3.stop.oneOf.0","typeLabel":"string"},{"type":"array","items":{"type":"string","uniqueKey":"oneOf.3.stop.oneOf.1.items.[INDEX]","typeLabel":"string"},"description":"Stop words, which will halt the output when a full match is found. The matched words themselves will not be output. A maximum of 5 strings is allowed, and each string must not exceed 32 bytes","maxItems":5,"uniqueKey":"oneOf.3.stop.oneOf.1","typeLabel":"string[]"}],"uniqueKey":"oneOf.3.stop","typeLabel":"string | string[]"},"stream":{"type":"boolean","default":false,"description":"Whether to return the response in a streaming fashion. Default is false.","uniqueKey":"oneOf.3.stream","typeLabel":"boolean"},"stream_options":{"type":"object","description":"Options for streaming responses","properties":{"include_usage":{"type":"boolean","default":false,"description":"If set, an additional chunk will be streamed before the data: [DONE] message. The usage field on this chunk shows the token usage statistics for the entire request, and the choices field will always be an empty array. All other chunks will also include a usage field, but with a null value. NOTE: If the stream is interrupted, you may not receive the final usage chunk which contains the total token usage for the request","uniqueKey":"oneOf.3.stream_options.include_usage","typeLabel":"boolean"}},"uniqueKey":"oneOf.3.stream_options","typeLabel":"object"},"tools":{"type":"array","description":"A list of tools the model may call","items":{"type":"object","properties":{"type":{"type":"string","enum":["function"],"isRequired":true,"uniqueKey":"oneOf.3.tools.items.[INDEX].type","typeLabel":"enum\u003cstring>"},"function":{"type":"object","properties":{"name":{"type":"string","description":"Function name. Must follow the regex: ^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$","pattern":"^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$","isRequired":true,"uniqueKey":"oneOf.3.tools.items.[INDEX].function.name","typeLabel":"string"},"parameters":{"type":"object","description":"Function parameters as JSON Schema. Must conform to the [MFJS (Moonshot Flavored JSON Schema) specification](https://github.com/MoonshotAI/walle/blob/main/docs/mfjs-spec.md).","additionalProperties":true,"isRequired":true,"uniqueKey":"oneOf.3.tools.items.[INDEX].function.parameters","typeLabel":"object"},"description":{"type":"string","description":"Description of what the function does","uniqueKey":"oneOf.3.tools.items.[INDEX].function.description","typeLabel":"string"},"strict":{"type":"boolean","default":true,"description":"Whether to strictly constrain tool call arguments according to the parameters schema. Defaults to true. When false, only guarantees the output is a valid JSON object without enforcing internal structure.","uniqueKey":"oneOf.3.tools.items.[INDEX].function.strict","typeLabel":"boolean"}},"required":["name","parameters"],"isRequired":true,"uniqueKey":"oneOf.3.tools.items.[INDEX].function","typeLabel":"object"}},"required":["type","function"],"uniqueKey":"oneOf.3.tools.items.[INDEX]","typeLabel":"object"},"uniqueKey":"oneOf.3.tools","typeLabel":"object[]"},"prompt_cache_key":{"type":"string","default":null,"description":"Used to cache responses for similar requests to optimize cache hit rates. For Coding Agents, this is typically a session id or task id representing a single session; if the session is exited and later resumed, this value should remain the same. For Kimi Code Plan, this field is required to improve cache hit rates. For other agents involving multi-turn conversations, it is also recommended to implement this field","uniqueKey":"oneOf.3.prompt_cache_key","typeLabel":"string"},"prompt_cache_options":{"type":"object","description":"Context cache write options. When omitted, cache write is enabled by default (5m tier): the system automatically writes the request prefix to the 5m cache tier","properties":{"mode":{"type":"string","enum":["implicit"],"default":"implicit","description":"Cache write mode. Only implicit is supported: automatically writes the request prefix to the cache","uniqueKey":"oneOf.3.prompt_cache_options.mode","typeLabel":"enum\u003cstring>"},"ttl":{"type":"string","enum":["5m","1h"],"default":"5m","description":"Lifetime of the written cache. The 5m and 1h tiers are independent of each other. When a request with the same prefix hits the cache within its lifetime, the cache entry is refreshed with its original TTL","uniqueKey":"oneOf.3.prompt_cache_options.ttl","typeLabel":"enum\u003cstring>"}},"uniqueKey":"oneOf.3.prompt_cache_options","typeLabel":"object"},"safety_identifier":{"type":"string","description":"A stable identifier used to help detect users of your application that may be violating usage policies. The ID should be a string that uniquely identifies each user. It is recommended to hash the username or email address to avoid sending any identifying information","uniqueKey":"oneOf.3.safety_identifier","typeLabel":"string"},"tool_choice":{"oneOf":[{"type":"string","description":"Controls whether the model calls tools. `auto` (default): the model decides whether to call tools; `none`: no tool calls; `required`: force a tool call; or pass an object specifying a particular function to force that tool call.","enum":["auto","none","required"],"uniqueKey":"oneOf.3.tool_choice.oneOf.0","typeLabel":"enum\u003cstring>"},{"type":"object","description":"Controls whether the model calls tools. `auto` (default): the model decides whether to call tools; `none`: no tool calls; `required`: force a tool call; or pass an object specifying a particular function to force that tool call.","required":["type","function"],"properties":{"type":{"type":"string","enum":["function"],"isRequired":true,"uniqueKey":"oneOf.3.tool_choice.oneOf.1.type","typeLabel":"enum\u003cstring>"},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call","isRequired":true,"uniqueKey":"oneOf.3.tool_choice.oneOf.1.function.name","typeLabel":"string"}},"required":["name"],"isRequired":true,"uniqueKey":"oneOf.3.tool_choice.oneOf.1.function","typeLabel":"object"}},"uniqueKey":"oneOf.3.tool_choice.oneOf.1","typeLabel":"object"}],"uniqueKey":"oneOf.3.tool_choice","typeLabel":"enum\u003cstring> | object"},"thinking":{"type":"object","description":"Controls whether thinking is enabled for the kimi-k2.6 model, and whether to fully preserve reasoning_content across multi-turn conversations. Optional parameter. Default value is {\"type\": \"enabled\"}.","properties":{"type":{"type":"string","enum":["enabled","disabled"],"description":"Enable or disable thinking capability","isRequired":true,"uniqueKey":"oneOf.3.thinking.type","typeLabel":"enum\u003cstring>"},"keep":{"oneOf":[{"type":"string","enum":["all",null],"description":"Controls whether reasoning_content from previous turns is preserved across a multi-turn conversation, i.e. whether to enable Preserved Thinking. Defaults to `null`, meaning historical thinking is NOT preserved.\n\n- `null` (default) or omitted: The server ignores reasoning_content from historical turns.\n- `\"all\"`: Preserves reasoning_content from historical turns and provides it to the model as part of the context, enabling Preserved Thinking. When using this, keep the reasoning_content from every historical assistant message in messages as-is. Recommended to use together with `type: \"enabled\"`.\n- Note: This parameter only affects reasoning_content from historical turns; it does not change whether the model produces/outputs thinking within the current turn (that is controlled by `type`). For best practices, see [Preserved Thinking](/guide/use-thinking-models#preserved-thinking).","uniqueKey":"oneOf.3.thinking.keep.oneOf.0","typeLabel":"enum\u003cstring>"},{"type":"null","enum":["all",null],"description":"Controls whether reasoning_content from previous turns is preserved across a multi-turn conversation, i.e. whether to enable Preserved Thinking. Defaults to `null`, meaning historical thinking is NOT preserved.\n\n- `null` (default) or omitted: The server ignores reasoning_content from historical turns.\n- `\"all\"`: Preserves reasoning_content from historical turns and provides it to the model as part of the context, enabling Preserved Thinking. When using this, keep the reasoning_content from every historical assistant message in messages as-is. Recommended to use together with `type: \"enabled\"`.\n- Note: This parameter only affects reasoning_content from historical turns; it does not change whether the model produces/outputs thinking within the current turn (that is controlled by `type`). For best practices, see [Preserved Thinking](/guide/use-thinking-models#preserved-thinking).","uniqueKey":"oneOf.3.thinking.keep.oneOf.1","typeLabel":"null"}],"uniqueKey":"oneOf.3.thinking.keep","typeLabel":"enum\u003cstring> | null"}},"required":["type"],"additionalProperties":false,"uniqueKey":"oneOf.3.thinking","typeLabel":"object"}},"uniqueKey":"oneOf.3","typeLabel":"kimi-k2.6 · object"}],"uniqueKey":"","typeLabel":"kimi-k3.1-pro series · object | kimi-k3 · object | kimi-k2.7-code · object | kimi-k2.6 · object"},"examples":{"Example":{"title":"Example","value":{"messages":[{"role":"user","content":"Hello","name":null,"partial":false}],"model":"kimi-k3.1-pro","logprobs":false,"top_logprobs":10,"prediction":{"type":"content","content":"\u003cstring>"},"max_tokens":123,"max_completion_tokens":123,"response_format":{},"stop":"\u003cstring>","stream":false,"stream_options":{"include_usage":false},"tools":[{"type":"function","function":{"name":"\u003cstring>","parameters":{},"description":"\u003cstring>","strict":true}}],"prompt_cache_key":null,"prompt_cache_options":{"mode":"implicit","ttl":"5m"},"safety_identifier":"\u003cstring>","reasoning_effort":"max"}}},"exampleType":"generated"}},"exampleType":"generated"},"responses":{"6014d158-acf5-4baa-bee6-01d37a7bc71b":{"description":"Chat completion response","headers":{"Msh-Request-Timestamp":{"description":"Unix timestamp in milliseconds at which the Kimi API accepted this request. Only returned when the request carries a valid `X-Msh-Request-Nonce`.","schema":{"type":"integer","format":"int64","example":1786338000123}},"Msh-Request-Signature":{"description":"Signature token prefixed with `reqsigv1_`, issued by the Kimi API over the nonce, timestamp, and the request's `model`; verify it with `POST /v1/signatures/verify`. Only returned when the request carries a valid `X-Msh-Request-Nonce`.","schema":{"type":"string","example":"reqsigv1_\u003copaque-token>"}}},"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier for the completion","uniqueKey":"id","typeLabel":"string"},"object":{"type":"string","description":"Object type","example":"chat.completion","uniqueKey":"object","typeLabel":"string"},"created":{"type":"integer","description":"Unix timestamp of when the completion was created","uniqueKey":"created","typeLabel":"integer"},"model":{"type":"string","description":"Model used for the completion","uniqueKey":"model","typeLabel":"string"},"choices":{"type":"array","description":"List of completion choices","items":{"type":"object","properties":{"index":{"type":"integer","uniqueKey":"choices.items.[INDEX].index","typeLabel":"integer"},"message":{"type":"object","properties":{"role":{"type":"string","enum":["assistant"],"uniqueKey":"choices.items.[INDEX].message.role","typeLabel":"enum\u003cstring>"},"content":{"oneOf":[{"type":"string","description":"The assistant's message content","uniqueKey":"choices.items.[INDEX].message.content.oneOf.0","typeLabel":"string"},{"type":"null","description":"The assistant's message content","uniqueKey":"choices.items.[INDEX].message.content.oneOf.1","typeLabel":"null"}],"uniqueKey":"choices.items.[INDEX].message.content","typeLabel":"string | null"},"tool_calls":{"type":"array","description":"Tool calls made by the model","items":{"type":"object","properties":{"id":{"type":"string","uniqueKey":"choices.items.[INDEX].message.tool_calls.items.[INDEX].id","typeLabel":"string"},"type":{"type":"string","enum":["function"],"uniqueKey":"choices.items.[INDEX].message.tool_calls.items.[INDEX].type","typeLabel":"enum\u003cstring>"},"function":{"type":"object","properties":{"name":{"type":"string","uniqueKey":"choices.items.[INDEX].message.tool_calls.items.[INDEX].function.name","typeLabel":"string"},"arguments":{"type":"string","description":"JSON string of function arguments","uniqueKey":"choices.items.[INDEX].message.tool_calls.items.[INDEX].function.arguments","typeLabel":"string"}},"uniqueKey":"choices.items.[INDEX].message.tool_calls.items.[INDEX].function","typeLabel":"object"}},"uniqueKey":"choices.items.[INDEX].message.tool_calls.items.[INDEX]","typeLabel":"object"},"uniqueKey":"choices.items.[INDEX].message.tool_calls","typeLabel":"object[]"},"reasoning_content":{"oneOf":[{"type":"string","description":"Reasoning process (returned only when thinking mode is enabled)","uniqueKey":"choices.items.[INDEX].message.reasoning_content.oneOf.0","typeLabel":"string"},{"type":"null","description":"Reasoning process (returned only when thinking mode is enabled)","uniqueKey":"choices.items.[INDEX].message.reasoning_content.oneOf.1","typeLabel":"null"}],"uniqueKey":"choices.items.[INDEX].message.reasoning_content","typeLabel":"string | null"}},"uniqueKey":"choices.items.[INDEX].message","typeLabel":"object"},"finish_reason":{"type":"string","enum":["stop","length","tool_calls"],"uniqueKey":"choices.items.[INDEX].finish_reason","typeLabel":"enum\u003cstring>"}},"uniqueKey":"choices.items.[INDEX]","typeLabel":"object"},"uniqueKey":"choices","typeLabel":"object[]"},"usage":{"type":"object","properties":{"prompt_tokens":{"type":"integer","description":"Number of tokens in the prompt","uniqueKey":"usage.prompt_tokens","typeLabel":"integer"},"completion_tokens":{"type":"integer","description":"Number of tokens in the completion","uniqueKey":"usage.completion_tokens","typeLabel":"integer"},"total_tokens":{"type":"integer","description":"Total number of tokens used","uniqueKey":"usage.total_tokens","typeLabel":"integer"},"cached_tokens":{"type":"integer","description":"Number of tokens served from cache","uniqueKey":"usage.cached_tokens","typeLabel":"integer"},"prompt_tokens_details":{"type":"object","description":"Breakdown of prompt tokens. cached_tokens, cache_write_tokens and the uncached remainder are mutually exclusive and sum to prompt_tokens","properties":{"cached_tokens":{"type":"integer","description":"Number of tokens served from cache","isRequired":true,"uniqueKey":"usage.prompt_tokens_details.cached_tokens","typeLabel":"integer"},"cache_write_tokens":{"type":"integer","description":"Number of tokens written to the cache by this request. Billed according to the TTL at write time; see prompt_cache_options","isRequired":true,"uniqueKey":"usage.prompt_tokens_details.cache_write_tokens","typeLabel":"integer"}},"required":["cached_tokens","cache_write_tokens"],"uniqueKey":"usage.prompt_tokens_details","typeLabel":"object"}},"uniqueKey":"usage","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"id":"\u003cstring>","object":"chat.completion","created":123,"model":"\u003cstring>","choices":[{"index":123,"message":{"role":"assistant","content":"\u003cstring>","tool_calls":[{"id":"\u003cstring>","type":"function","function":{"name":"\u003cstring>","arguments":"\u003cstring>"}}],"reasoning_content":"\u003cstring>"},"finish_reason":"stop"}],"usage":{"prompt_tokens":123,"completion_tokens":123,"total_tokens":123,"cached_tokens":123,"prompt_tokens_details":{"cached_tokens":123,"cache_write_tokens":123}}}}},"exampleType":"generated"},"text/event-stream":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier for the completion","uniqueKey":"id","typeLabel":"string"},"object":{"type":"string","description":"Object type","example":"chat.completion.chunk","uniqueKey":"object","typeLabel":"string"},"created":{"type":"integer","description":"Unix timestamp of when the completion was created","uniqueKey":"created","typeLabel":"integer"},"model":{"type":"string","description":"Model used for the completion","uniqueKey":"model","typeLabel":"string"},"choices":{"type":"array","description":"List of completion choices","items":{"type":"object","properties":{"index":{"type":"integer","description":"Choice index","uniqueKey":"choices.items.[INDEX].index","typeLabel":"integer"},"delta":{"type":"object","description":"Incremental content object","properties":{"role":{"type":"string","description":"Message role (only present in the first chunk)","uniqueKey":"choices.items.[INDEX].delta.role","typeLabel":"string"},"content":{"type":"string","description":"Message content fragment","uniqueKey":"choices.items.[INDEX].delta.content","typeLabel":"string"},"tool_calls":{"type":"array","description":"Tool calls initiated by the model","items":{"type":"object","properties":{"id":{"type":"string","uniqueKey":"choices.items.[INDEX].delta.tool_calls.items.[INDEX].id","typeLabel":"string"},"type":{"type":"string","enum":["function"],"uniqueKey":"choices.items.[INDEX].delta.tool_calls.items.[INDEX].type","typeLabel":"enum\u003cstring>"},"function":{"type":"object","properties":{"name":{"type":"string","uniqueKey":"choices.items.[INDEX].delta.tool_calls.items.[INDEX].function.name","typeLabel":"string"},"arguments":{"type":"string","description":"JSON string of function arguments","uniqueKey":"choices.items.[INDEX].delta.tool_calls.items.[INDEX].function.arguments","typeLabel":"string"}},"uniqueKey":"choices.items.[INDEX].delta.tool_calls.items.[INDEX].function","typeLabel":"object"}},"uniqueKey":"choices.items.[INDEX].delta.tool_calls.items.[INDEX]","typeLabel":"object"},"uniqueKey":"choices.items.[INDEX].delta.tool_calls","typeLabel":"object[]"}},"uniqueKey":"choices.items.[INDEX].delta","typeLabel":"object"},"finish_reason":{"oneOf":[{"type":"string","enum":["stop","length","tool_calls",null],"description":"Stop reason, only present in the final chunk","uniqueKey":"choices.items.[INDEX].finish_reason.oneOf.0","typeLabel":"enum\u003cstring>"},{"type":"null","enum":["stop","length","tool_calls",null],"description":"Stop reason, only present in the final chunk","uniqueKey":"choices.items.[INDEX].finish_reason.oneOf.1","typeLabel":"null"}],"uniqueKey":"choices.items.[INDEX].finish_reason","typeLabel":"enum\u003cstring> | null"},"usage":{"type":"object","description":"Token usage statistics (optional)","properties":{"prompt_tokens":{"type":"integer","description":"Number of tokens in the prompt","uniqueKey":"choices.items.[INDEX].usage.prompt_tokens","typeLabel":"integer"},"completion_tokens":{"type":"integer","description":"Number of tokens in the completion","uniqueKey":"choices.items.[INDEX].usage.completion_tokens","typeLabel":"integer"},"total_tokens":{"type":"integer","description":"Total number of tokens used","uniqueKey":"choices.items.[INDEX].usage.total_tokens","typeLabel":"integer"}},"uniqueKey":"choices.items.[INDEX].usage","typeLabel":"object"}},"uniqueKey":"choices.items.[INDEX]","typeLabel":"object"},"uniqueKey":"choices","typeLabel":"object[]"},"usage":{"oneOf":[{"type":"object","description":"Token usage statistics. Object in the final chunk with usage, null in ordinary chunks","properties":{"prompt_tokens":{"type":"integer","description":"Number of tokens in the prompt","uniqueKey":"usage.oneOf.0.prompt_tokens","typeLabel":"integer"},"completion_tokens":{"type":"integer","description":"Number of tokens in the completion","uniqueKey":"usage.oneOf.0.completion_tokens","typeLabel":"integer"},"total_tokens":{"type":"integer","description":"Total number of tokens used","uniqueKey":"usage.oneOf.0.total_tokens","typeLabel":"integer"},"cached_tokens":{"type":"integer","description":"Number of tokens served from cache","uniqueKey":"usage.oneOf.0.cached_tokens","typeLabel":"integer"},"prompt_tokens_details":{"type":"object","description":"Breakdown of prompt tokens. cached_tokens, cache_write_tokens and the uncached remainder are mutually exclusive and sum to prompt_tokens","properties":{"cached_tokens":{"type":"integer","description":"Number of tokens served from cache","isRequired":true,"uniqueKey":"usage.oneOf.0.prompt_tokens_details.cached_tokens","typeLabel":"integer"},"cache_write_tokens":{"type":"integer","description":"Number of tokens written to the cache by this request. Billed according to the TTL at write time; see prompt_cache_options","isRequired":true,"uniqueKey":"usage.oneOf.0.prompt_tokens_details.cache_write_tokens","typeLabel":"integer"}},"required":["cached_tokens","cache_write_tokens"],"uniqueKey":"usage.oneOf.0.prompt_tokens_details","typeLabel":"object"}},"uniqueKey":"usage.oneOf.0","typeLabel":"object"},{"type":"null","description":"Token usage statistics. Object in the final chunk with usage, null in ordinary chunks","properties":{"prompt_tokens":{"type":"integer","description":"Number of tokens in the prompt"},"completion_tokens":{"type":"integer","description":"Number of tokens in the completion"},"total_tokens":{"type":"integer","description":"Total number of tokens used"},"cached_tokens":{"type":"integer","description":"Number of tokens served from cache"},"prompt_tokens_details":{"type":"object","description":"Breakdown of prompt tokens. cached_tokens, cache_write_tokens and the uncached remainder are mutually exclusive and sum to prompt_tokens","properties":{"cached_tokens":{"type":"integer","description":"Number of tokens served from cache"},"cache_write_tokens":{"type":"integer","description":"Number of tokens written to the cache by this request. Billed according to the TTL at write time; see prompt_cache_options"}},"required":["cached_tokens","cache_write_tokens"]}},"uniqueKey":"usage.oneOf.1","typeLabel":"null"}],"uniqueKey":"usage","typeLabel":"object | null"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"id":"\u003cstring>","object":"chat.completion.chunk","created":123,"model":"\u003cstring>","choices":[{"index":123,"delta":{"role":"\u003cstring>","content":"\u003cstring>","tool_calls":[{"id":"\u003cstring>","type":"function","function":{"name":"\u003cstring>","arguments":"\u003cstring>"}}]},"finish_reason":"stop","usage":{"prompt_tokens":123,"completion_tokens":123,"total_tokens":123}}],"usage":{"prompt_tokens":123,"completion_tokens":123,"total_tokens":123,"cached_tokens":123,"prompt_tokens_details":{"cached_tokens":123,"cache_write_tokens":123}}}}},"exampleType":"generated"}},"exampleType":"generated"},"c3cea2de-0250-4e5e-92d4-fb30d2aa8343":{"description":"Bad request - Invalid parameters","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string","description":"Error message describing what went wrong","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","description":"Error type","uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","description":"Error code","uniqueKey":"error.code","typeLabel":"string"}},"required":["message"],"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"required":["error"],"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>"}}}},"exampleType":"generated"}},"exampleType":"generated"},"eb5a2cf0-f59a-4b06-8ee6-4c64710e936b":{"description":"Unauthorized - Invalid or missing API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string","description":"Error message describing what went wrong","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","description":"Error type","uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","description":"Error code","uniqueKey":"error.code","typeLabel":"string"}},"required":["message"],"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"required":["error"],"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>"}}}},"exampleType":"generated"}},"exampleType":"generated"},"70c54761-da90-478d-ab97-4a480a40e7d3":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string","description":"Error message describing what went wrong","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","description":"Error type","uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","description":"Error code","uniqueKey":"error.code","typeLabel":"string"}},"required":["message"],"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"required":["error"],"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>"}}}},"exampleType":"generated"}},"exampleType":"generated"}},"security":{"ad178f96-64b2-4a2b-b5b5-5d694f0839a6":{"bearerAuth":{"type":"http","scheme":"bearer","description":"The Authorization header expects a Bearer token. Use an MOONSHOT_API_KEY as the token. This is a server-side secret key. Generate one on the [API keys page](https://platform.kimi.ai/console/api-keys) in your dashboard.","scopes":[],"schemeName":"bearerAuth"}}},"servers":{"f283f8d4-efce-425c-b24a-ee8368b5c4e3":{"url":"https://api.moonshot.ai","description":"Production"}},"processedSecurityOptions":[{"schemes":[{"scheme":{"type":"http","scheme":"bearer","description":"The Authorization header expects a Bearer token. Use an MOONSHOT_API_KEY as the token. This is a server-side secret key. Generate one on the [API keys page](https://platform.kimi.ai/console/api-keys) in your dashboard.","scopes":[],"schemeName":"bearerAuth"},"schema":{"title":"Bearer Auth","type":"string","isRequired":true,"description":"The Authorization header expects a Bearer token. Use an MOONSHOT_API_KEY as the token. This is a server-side secret key. Generate one on the [API keys page](https://platform.kimi.ai/console/api-keys) in your dashboard.","format":"bearer","typeLabel":"string\u003cbearer>","deprecated":false},"schemeName":"bearerAuth","name":"Authorization"}],"title":"bearerAuth"}]},"originalFileLocation":"openapi.json"},"subdomain":"moonshotai","siteName":"Kimi API Platform","title":"Chat Completions API - Kimi API Platform","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-23T17:23:00.822Z","originalFileLocation":"api/chat.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Create a chat completion: send messages to Kimi models and get replies, with streaming, tool calling, and vision input.\">\u003cmeta data-mint-head name=\"keywords\" content=\"Kimi K3.1 Pro,kimi-k3.1-pro,Kimi K3,Moonshot AI,K3 Large Language Model,AI API,Tool Calling,Code Generation,Intelligent Dialogue,AI Agent,Open-source Model,Long Context,Claw Bot\">\u003cmeta data-mint-head name=\"application-name\" content=\"Kimi API Platform\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003cmeta data-mint-head name=\"robots\" content=\"index,follow\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/moonshotai/6rzjGwhLi_bSodW_/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/docs/mintlify-assets/_mintlify/favicons/moonshotai/6rzjGwhLi_bSodW_/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/moonshotai/6rzjGwhLi_bSodW_/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/moonshotai/6rzjGwhLi_bSodW_/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/moonshotai/6rzjGwhLi_bSodW_/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/moonshotai/6rzjGwhLi_bSodW_/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/moonshotai/6rzjGwhLi_bSodW_/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/moonshotai/6rzjGwhLi_bSodW_/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/moonshotai/6rzjGwhLi_bSodW_/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Chat Completions API - Kimi API Platform\">\u003cmeta data-mint-head property=\"og:description\" content=\"Create a chat completion: send messages to Kimi models and get replies, with streaming, tool calling, and vision input.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Kimi API Platform\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://platform.kimi.ai/docs/api/chat\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://platform.kimi.ai/og.png?v=1\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Chat Completions API - Kimi API Platform\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Create a chat completion: send messages to Kimi models and get replies, with streaming, tool calling, and vision input.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://platform.kimi.ai/og.png?v=1\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/docs/mintlify-assets/_mintlify/favicons/moonshotai/6rzjGwhLi_bSodW_/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Kimi API Platform\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#111111\">\u003cmeta data-mint-head name=\"og:locale\" content=\"en-US\">\u003cmeta data-mint-head name=\"og:image:alt\" content=\"Kimi API Platform\">\u003clink data-mint-head rel=\"canonical\" href=\"https://platform.kimi.ai/docs/api/chat\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/api/chat.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://platform.kimi.ai/#organization\",\"name\":\"Kimi API Platform\",\"url\":\"https://platform.kimi.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/moonshotai/X_5b_eA1iuJP595e/assets/logo/light.svg?fit=max\u0026auto=format\u0026n=X_5b_eA1iuJP595e\u0026q=85\u0026s=f68cf2d80f8d7f0363e088d2b988a598\"}},{\"@type\":\"WebSite\",\"@id\":\"https://platform.kimi.ai/docs#website\",\"name\":\"Kimi API Platform\",\"url\":\"https://platform.kimi.ai/docs\",\"publisher\":{\"@id\":\"https://platform.kimi.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://platform.kimi.ai/docs/api/chat#webpage\",\"url\":\"https://platform.kimi.ai/docs/api/chat\",\"name\":\"Chat Completions API\",\"description\":\"Create a chat completion: send messages to Kimi models and get replies, with streaming, tool calling, and vision input.\",\"dateModified\":\"2026-10-23T17:23:00.822Z\",\"isPartOf\":{\"@id\":\"https://platform.kimi.ai/docs#website\"},\"breadcrumb\":{\"@id\":\"https://platform.kimi.ai/docs/api/chat#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://platform.kimi.ai/docs/api/chat#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Kimi API Platform\",\"item\":\"https://platform.kimi.ai/docs\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Chat Completions API\",\"item\":\"https://platform.kimi.ai/docs/api/chat\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://platform.kimi.ai/docs/api/chat#apireference\",\"headline\":\"Chat Completions API\",\"name\":\"Chat Completions API\",\"description\":\"Create a chat completion: send messages to Kimi models and get replies, with streaming, tool calling, and vision input.\",\"url\":\"https://platform.kimi.ai/docs/api/chat\",\"mainEntityOfPage\":{\"@id\":\"https://platform.kimi.ai/docs/api/chat#webpage\"},\"image\":\"https://platform.kimi.ai/og.png?v=1\",\"dateModified\":\"2026-10-23T17:23:00.822Z\",\"publisher\":{\"@id\":\"https://platform.kimi.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://platform.kimi.ai/docs#website\"}}]}\u003c/script>","siteName":"Kimi API Platform","nav":{"global":null,"tabs":[{"tab":"Guides","pages":[{"title":"Guides","href":"/get-your-api-key"}]},{"tab":"API Reference","groups":[{"group":"Using the API","pages":[{"title":"API Overview","sidebarTitle":"API Overview","href":"/api/overview"},{"title":"Model Parameter Reference","sidebarTitle":"Model Parameter Reference","href":"/api/models-overview"},{"title":"Common Error Codes","sidebarTitle":"Error Codes","description":"Look up Kimi API HTTP status codes, error types, common causes, and recommended troubleshooting steps.","href":"/api/errors"}]},{"group":"API Reference","pages":[{"title":"Chat Completions API","sidebarTitle":"Chat Completions API","openapi":"POST /v1/chat/completions","href":"/api/chat"},{"title":"Responses API","sidebarTitle":"Responses API","description":"Creates a model response. Provide text or image inputs to generate text or JSON outputs. Have the model call the function tools you define, or use server-side web search.","openapi":"POST /v1/responses","href":"/api/responses"},{"title":"Messages API","sidebarTitle":"Messages API","openapi":"POST /anthropic/v1/messages","href":"/api/messages"},{"title":"List Models","sidebarTitle":"List Models","openapi":"GET /v1/models","href":"/api/list-models"},{"title":"Estimate Tokens","sidebarTitle":"Estimate Tokens","openapi":"POST /v1/tokenizers/estimate-token-count","href":"/api/estimate"},{"title":"Check Balance","sidebarTitle":"Check Balance","openapi":"GET /v1/users/me/balance","href":"/api/balance"},{"title":"Verify Request Signature","sidebarTitle":"Verify Request Signature","openapi":"POST /v1/signatures/verify","href":"/api/signatures-verify"}]},{"group":"Tools","pages":[{"title":"Web Search Basic","sidebarTitle":"Web Search Basic","openapi":"POST /v1/tools/search","href":"/api/tools-search"},{"title":"Web Search Pro","sidebarTitle":"Web Search Pro","openapi":"POST /v1/tools/search_pro","href":"/api/tools-search-pro"},{"title":"URL Fetch","sidebarTitle":"URL Fetch","openapi":"POST /v1/tools/fetch","href":"/api/tools-fetch"}]},{"group":"Files","pages":[{"title":"Upload File","sidebarTitle":"Upload File","openapi":"POST /v1/files","href":"/api/files-upload"},{"title":"List Files","sidebarTitle":"List Files","openapi":"GET /v1/files","href":"/api/files-list"},{"title":"Get File Information","sidebarTitle":"Get File Information","openapi":"GET /v1/files/{file_id}","href":"/api/files-retrieve"},{"title":"Delete File","sidebarTitle":"Delete File","openapi":"DELETE /v1/files/{file_id}","href":"/api/files-delete"},{"title":"Get File Content","sidebarTitle":"Get File Content","openapi":"GET /v1/files/{file_id}/content","href":"/api/files-content"}]},{"group":"Batch API","pages":[{"title":"Create Batch","sidebarTitle":"Create Batch","openapi":"POST /v1/batches","href":"/api/batch-create"},{"title":"List Batches","sidebarTitle":"List Batches","openapi":"GET /v1/batches","href":"/api/batch-list"},{"title":"Retrieve Batch","sidebarTitle":"Retrieve Batch","openapi":"GET /v1/batches/{batch_id}","href":"/api/batch-retrieve"},{"title":"Cancel Batch","sidebarTitle":"Cancel Batch","openapi":"POST /v1/batches/{batch_id}/cancel","href":"/api/batch-cancel"}]},{"group":"Admin API","tag":"Beta","pages":[{"title":"Admin API overview","sidebarTitle":"Overview","href":"/admin-api/overview"},{"group":"Billing","pages":[{"title":"List daily bills","openapi":"GET /v1/admin/organizations/billings/daily_bills","href":"/admin-api/billing-daily-bills"},{"title":"List product bills","openapi":"GET /v1/admin/organizations/billings/product_bills","href":"/admin-api/billing-product-bills"},{"title":"List request details","openapi":"GET /v1/admin/organizations/billings/request_details","href":"/admin-api/billing-request-details"},{"title":"List interrupted requests","openapi":"GET /v1/admin/organizations/billings/interrupted_requests","href":"/admin-api/billing-interrupted-requests"},{"title":"Get account balance","openapi":"GET /v1/admin/organizations/account","href":"/admin-api/billing-account"}]},{"group":"Audit Logs","pages":[{"title":"List audit log events","openapi":"GET /v1/admin/organizations/audit_logs","href":"/admin-api/audit-logs"}]},{"group":"Usage","pages":[{"title":"Get usage aggregation","openapi":"GET /v1/admin/organizations/usage/{usage_type}","href":"/admin-api/usage"}]},{"group":"Organization","pages":[{"title":"Get organization info","openapi":"GET /v1/admin/organizations","href":"/admin-api/organization"},{"group":"Members \u0026 Invitations","pages":[{"title":"List members","openapi":"GET /v1/admin/organizations/members","href":"/admin-api/members"},{"title":"Get member","openapi":"GET /v1/admin/organizations/members/{uid}","href":"/admin-api/member"},{"title":"Update member role","openapi":"PATCH /v1/admin/organizations/members/{uid}","href":"/admin-api/member-update-role"},{"title":"Remove member","openapi":"DELETE /v1/admin/organizations/members/{uid}","href":"/admin-api/member-remove"},{"title":"List invitations","openapi":"GET /v1/admin/organizations/invites","href":"/admin-api/invites"},{"title":"Get invitation","openapi":"GET /v1/admin/organizations/invites/{code}","href":"/admin-api/invite"},{"title":"Create invitation","openapi":"POST /v1/admin/organizations/invites","href":"/admin-api/invite-create"}]},{"group":"Projects","pages":[{"title":"List projects","openapi":"GET /v1/admin/organizations/projects","href":"/admin-api/projects"},{"title":"Get project","openapi":"GET /v1/admin/organizations/projects/{pid}","href":"/admin-api/project"},{"title":"Create project","openapi":"POST /v1/admin/organizations/projects","href":"/admin-api/project-create"},{"title":"Update project","openapi":"PATCH /v1/admin/organizations/projects/{pid}","href":"/admin-api/project-update"},{"title":"Archive project","openapi":"POST /v1/admin/organizations/projects/{pid}/archive","href":"/admin-api/project-archive"}]},{"group":"Project Members","pages":[{"title":"List project members","openapi":"GET /v1/admin/organizations/projects/{pid}/members","href":"/admin-api/project-members"},{"title":"Add project member","openapi":"POST /v1/admin/organizations/projects/{pid}/members","href":"/admin-api/project-member-add"},{"title":"Update project member role","openapi":"PATCH /v1/admin/organizations/projects/{pid}/members/{uid}","href":"/admin-api/project-member-update-role"},{"title":"Remove project member","openapi":"DELETE /v1/admin/organizations/projects/{pid}/members/{uid}","href":"/admin-api/project-member-remove"}]},{"group":"API Keys","pages":[{"title":"List project API keys","openapi":"GET /v1/admin/organizations/projects/{pid}/api_keys","href":"/admin-api/project-api-keys"},{"title":"Get API key metadata","openapi":"GET /v1/admin/organizations/api_keys/{key}","href":"/admin-api/api-key"},{"title":"Rename API key","openapi":"PATCH /v1/admin/organizations/projects/{pid}/api_keys/{key}","href":"/admin-api/api-key-rename"},{"title":"Revoke API key","openapi":"DELETE /v1/admin/organizations/projects/{pid}/api_keys/{key}","href":"/admin-api/api-key-revoke"}]},{"group":"Configuration","pages":[{"title":"Get organization rate limits","openapi":"GET /v1/admin/organizations/rate_limits","href":"/admin-api/rate-limits"},{"title":"Get project spend limit","openapi":"GET /v1/admin/organizations/projects/{pid}/spend_limits","href":"/admin-api/project-spend-limits"},{"title":"Update project spend limit","openapi":"PATCH /v1/admin/organizations/projects/{pid}/spend_limits","href":"/admin-api/project-spend-limits-update"}]}]}]}]},{"tab":"Models \u0026 Pricing","pages":[{"title":"Models \u0026 Pricing","href":"/pricing/chat"}]},{"tab":"Resources","menu":[{"item":"Community","icon":"users","pages":[{"title":"Community","href":"/api/join-the-community"}]},{"item":"Playground","icon":"terminal","href":"https://platform.kimi.ai/playground"},{"item":"Help Center","icon":"circle-question","pages":[{"title":"Help Center","href":"/guide/account-and-payments"}]},{"item":"Learning and support","icon":"book-open","pages":[{"title":"Learning and support","href":"/guide/ask-questions-about-pdf-content"}]},{"item":"Legal","icon":"file-text","pages":[{"title":"Legal","href":"/agreement/modeluse"}]},{"item":"Changelog","icon":"list","pages":[{"title":"Changelog","href":"/platform-changelog"}]}],"pages":[{"title":"Resources","href":"/api/join-the-community"}]}]},"basePath":"","title":"Chat Completions API - Kimi API Platform","buildId":"dpl_ATnXPMW25DMPUr9VBw6kL6MfBt6T","deploymentId":"dpl_ATnXPMW25DMPUr9VBw6kL6MfBt6T","dynamics":["10e4515597","c2aa737661","b0f84f53ff","a9bb46feb3","2b790eda92"],"chunks":["BannerMarkdown-B5WzX-8C.js","dist-BPypQKlo.js","lib-DuNMoZ05.js","lib-B8HbPgcC.js","clsx-6wHzaN2_.js","html-void-elements-mCSPHezU.js","katex-YMM-FMeD.js","marked.esm-CZWythHk.js","OpenApiReferenceProvider-CNqlzjVB.js","utils-BqFiXZ79.js","cloneDeep-izs3Hzxb.js","_Uint8Array-BVIqJ90l.js","isObjectLike-C8vmzPEN.js","isArray-Dcu1dQ5t.js","utils-CnR4QBe6.js","toString-BX-iyh8G.js","isSymbol-CSH9U2Gm.js","addUniqueKeysToSchema-BY2ZM1OO.js","snippetPresets-x-8ACO8V.js","style-to-object-BY3JEAdk.js","v4-DIgz8zy6.js","Page-CTxrMSpo.js","ApiExamples-Ch-SJE05.js","isEqual-BfaiBbcl.js","usePlaygroundInputsStore-CqqG_0NE.js","shallow-BXrZ2b0C.js","getApiPlaygroundDisplay-n7J_wkjq.js","CodeSnippet-CQsp4vyQ.js","CodeSnippets-BfuHqvZx.js","getPastedJson-BjrGIK1i.js","icon-7iLZnVOC.js","MethodPill-TBS1m84e.js","DuplicateIcon-BNMrV4Vs.js","createIcon-C5kCqeU2.js","DynamicMarkdown-Bq09mRwR.js","SectionHeading-G4Bflf5Q.js","axios-vUo_bRtp.js","Markdown-BTUds0aX.js","AssistantPageLink-o6bee4ro.js"]}