Kimi K3 (長程程式設計 / 推理)

Kimi K3 是月之暗面旗艦模型, 1M token 上下文, 始終開啟思考模式, 面向長程程式設計與端到端知識工作. OpenAI 相容 /v1/chat/completions.

POST /v1/chat/completions

## Kimi K3 Kimi K3 是月之暗面 (Moonshot) 面向長程程式設計與端到端知識工作的旗艦模型, 支援 **1M (1,048,576) token** 上下文, 綜合智慧領先. - **始終開啟思考**: K3 預設產生 `reasoning_content` 推理內容, 這部分推理 token **計入輸出 token 消耗**, 因此實際輸出用量會高於最終可見回答的文字量. - 支援 **工具呼叫 (tools / tool_choice)**、**JSON Mode / 結構化輸出 (response_format)**、**聯網搜尋**、**Partial Mode**、**動態載入工具**. - 通過頂層 `reasoning_effort` 配置推理力度 (當前僅 `max` 檔位). - 自動上下文快取: 命中的輸入 token 會在 `usage.prompt_tokens_details.cached_tokens` 中返回. ### 呼叫地址 ``` POST https://api.router.ai/v1/chat/completions Authorization: Bearer sk-your-api-key Content-Type: application/json ```

请求体

modelstringrequired模型 ID, 固定 `kimi-k3`
messagesarrayrequiredOpenAI 相容多輪對話陣列, 每個元素含 `role` (system/user/assistant/tool) + `content` (string 或多模態陣列), 按時間順序傳入
reasoning_effortstring推理力度, 當前僅支援 `max`. 省略則使用預設思考行為
max_tokensinteger輸出 token 上限 (含推理過程 token + 可見回答 token). 省略則不限制
toolsarray工具 (函式) 定義陣列, OpenAI 相容格式
tool_choicestring | object工具選擇策略: `auto` / `none` / `required` / `{type:'function',function:{name:'X'}}`
response_formatobject結構化輸出: `{"type":"json_object"}` (JSON Mode) 或 `{"type":"json_schema","json_schema":{...}}` (JSON Schema)
streamboolean是否流式返回 (SSE). 預設 false
temperaturenumber取樣溫度, 越大越隨機
top_pnumber核取樣閾值
ninteger候選回覆數量, 預設 1

响应

调用示例

curl https://api.router.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3",
    "messages": [
      {"role": "user", "content": "用一句话介绍你自己"}
    ],
    "reasoning_effort": "max"
  }'

API 文件