Skip to content

Kimi K3 ​

Kimi K3 is available through the OpenAI-compatible Chat Completions API. It supports text and image input, reasoning content, streaming, and function calling.

Endpoint ​

http
POST /v1/chat/completions

Model ​

text
kimi-k3

Actual availability and quota depend on your account permissions.

Basic Request ​

bash
curl https://cubicspaces.cloud/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3",
    "messages": [
      { "role": "system", "content": "You are a precise and concise technical assistant." },
      { "role": "user", "content": "List three principles for designing an idempotent API." }
    ],
    "reasoning_effort": "high",
    "max_tokens": 4096,
    "stream": false
  }'

In a non-streaming response, the final answer is returned in choices[0].message.content. When reasoning content is present, it is returned in choices[0].message.reasoning_content.

Reasoning Effort ​

reasoning_effort accepts these values:

ValueDescription
lowShorter reasoning for simple tasks
highDeeper reasoning for complex analysis and coding
maxMaximum reasoning effort and potentially longer output

Do not use medium or any unlisted value. Unsupported values return HTTP 400.

Image Input ​

Place images in the user message's content array using the OpenAI image_url format. A publicly accessible HTTPS URL is recommended.

json
{
  "model": "kimi-k3",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "image_url",
          "image_url": {
            "url": "https://example.com/image.jpg"
          }
        },
        {
          "type": "text",
          "text": "Describe this image and list its three most important details."
        }
      ]
    }
  ],
  "reasoning_effort": "high",
  "max_tokens": 4096
}

Streaming ​

bash
curl https://cubicspaces.cloud/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3",
    "messages": [
      { "role": "user", "content": "Analyze the risks in this database migration plan." }
    ],
    "reasoning_effort": "high",
    "stream": true,
    "stream_options": {
      "include_usage": true
    }
  }'

Streaming responses use SSE. Parse these fields separately:

  • choices[0].delta.reasoning_content: reasoning chunks.
  • choices[0].delta.content: final-answer chunks.
  • usage: returned near the end when stream_options.include_usage is enabled.
  • data: [DONE]: end-of-stream marker.

Function Calling ​

Tools must use the OpenAI Function Calling format. tools must be an array, and every tool must contain type: "function" and a complete function object.

json
{
  "model": "kimi-k3",
  "messages": [
    { "role": "user", "content": "Check the current weather in Tokyo." }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get the weather for a city",
        "parameters": {
          "type": "object",
          "properties": {
            "city": { "type": "string" }
          },
          "required": ["city"]
        }
      }
    }
  ],
  "tool_choice": "auto",
  "reasoning_effort": "high"
}

Function names must follow these rules:

  • No more than 64 characters.
  • Only ASCII letters, numbers, underscores, and hyphens.
  • function.parameters must be a JSON object.

After the model returns tool_calls, execute the tools and append their results to the message history:

json
{
  "model": "kimi-k3",
  "messages": [
    { "role": "user", "content": "Check the current weather in Tokyo." },
    {
      "role": "assistant",
      "content": null,
      "tool_calls": [
        {
          "id": "call_1",
          "type": "function",
          "function": {
            "name": "get_weather",
            "arguments": "{\"city\":\"Tokyo\"}"
          }
        }
      ]
    },
    {
      "role": "tool",
      "tool_call_id": "call_1",
      "content": "Sunny, 26°C"
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "parameters": {
          "type": "object",
          "properties": {
            "city": { "type": "string" }
          },
          "required": ["city"]
        }
      }
    }
  ]
}

Every role: "tool" message must use the exact tool_calls[].id returned by the preceding assistant message. Return a result for every tool call before sending the next regular message.

Python SDK ​

python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://cubicspaces.cloud/v1",
)

response = client.chat.completions.create(
    model="kimi-k3",
    messages=[
        {"role": "user", "content": "Explain optimistic locking."}
    ],
    reasoning_effort="high",
    max_tokens=4096,
)

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

Parameters ​

ParameterTypeDescription
modelstringMust be kimi-k3
messagesarrayOpenAI Chat message array
reasoning_effortstringlow, high, or max
max_tokensintegerMaximum output tokens; recommended for this model
max_completion_tokensintegerMaximum output tokens; accepted by some clients
streambooleanWhether to stream the response
stream_optionsobjectStreaming options such as include_usage
toolsarrayFunction Calling tool definitions
tool_choicestring/objectTool selection policy

The platform currently limits the requested output maximum to 65,536 tokens. Use a smaller practical value whenever possible.

Parameters to Omit ​

To avoid compatibility errors, do not add these fields to Kimi K3 requests:

  • temperature
  • top_p
  • top_k
  • presence_penalty
  • frequency_penalty
  • prompt_cache_key
  • prompt_cache_retention
  • A literal extra_body field in raw HTTP JSON
  • Legacy functions or function_call

The Python SDK does not require extra_body for Kimi K3. If another client provides an advanced field named Extra Body, do not place unknown extensions in it.

Common HTTP 400 Errors ​

SymptomCommon causeResolution
Unsupported reasoning_effortmedium or a custom value was usedUse low, high, or max
tools[n].function.name errorMissing, overlong, or invalid function nameFollow the function-name rules above
function.parameters must be a JSON objectThe schema was sent as a string or arraySend a valid JSON object
tool_call_id does not matchA tool result has no matching prior callReuse the original tool_calls[].id
All tool results must be returned firstOnly some parallel tool calls received resultsAppend one role: "tool" message for every call
Invalid messages or tools structureObjects and arrays were mixed, or an item is incompleteCompare the final JSON hierarchy with the examples above
JSON parsing errorTruncated payload or incorrect quote/backslash escapingValidate the final HTTP request body with a JSON parser

When troubleshooting, inspect the final HTTP JSON sent by the client, not only the SDK call. Proxies, plugins, and advanced client settings may add fields to the final payload.