Skip to main content
POST
Messages API
Call Kimi models using an Anthropic Messages API compatible format. If you already use the Anthropic SDK, Claude Code, or similar tools, simply point the base URL at https://api.moonshot.ai/anthropic to call Kimi models directly.

Authorizations

Authorization
string
header
required

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.

Body

application/json
model
enum<string>
default:kimi-k3
required

Model ID

Available options:
kimi-k3
messages
object[]
required

The conversation messages. If the last message is from the assistant, the model continues from that content (Partial Mode).

max_tokens
integer
required

Maximum number of tokens to generate, required. If the limit is reached before the model finishes, stop_reason is max_tokens.

Required range: x >= 1
system

System prompt, either a string or an array of text blocks

stream
boolean
default:false

Whether to stream the response as Server-Sent Events, default false

stop_sequences
string[]

Stop sequences. Generation stops on an exact match; the matched sequence itself is not output. Up to 5 entries, each at most 32 bytes.

Maximum array length: 5
tools
object[]

List of tools the model may call

tool_choice
object

Controls whether the model calls tools. auto (default): the model decides; any: force a call to any tool; none: do not call tools.

metadata
object
output_config
object

Output configuration: reasoning effort and structured output

Response

Message response

id
string

Unique identifier of the response

type
enum<string>
Available options:
message
Example:

"message"

role
enum<string>
Available options:
assistant
model
string

The model specified in the request

content
(thinking · object | text · object | tool_use · object)[]

Content blocks, ordered thinking → text → tool_use

stop_reason
enum<string> | null

Stop reason. end_turn: finished naturally (including a stop_sequences match); max_tokens: reached the max_tokens limit; tool_use: the model issued a tool call; refusal: content safety review was triggered.

Available options:
end_turn,
max_tokens,
tool_use,
refusal,
null
stop_sequence
string | null

The stop sequence that was matched

usage
object

Token usage