跳转到主要内容
POST
/
v1
/
chat
/
completions
curl --request POST \
--url https://api.evolink.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "kimi-k2-thinking",
"messages": [
{
"role": "user",
"content": "请介绍一下你自己"
}
],
"temperature": 1
}'
{
  "id": "cmpl-04ea926191a14749b7f2c7a48a68abc6",
  "model": "kimi-k2-thinking",
  "object": "chat.completion",
  "created": 1698999496,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hi there! How can I help you?",
        "reasoning_content": "The user just said \"hi\". This is a very simple greeting. I should be friendly, helpful, and professional in my response..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 8,
    "completion_tokens": 292,
    "total_tokens": 300,
    "prompt_tokens_details": {
      "cached_tokens": 8
    }
  }
}

Authorizations

Authorization
string
header
required

##所有接口均需要使用Bearer Token进行认证##

获取 API Key :

访问 API Key 管理页面 获取您的 API Key

使用时在请求头中添加:

Authorization: Bearer YOUR_API_KEY

Body

application/json
model
enum<string>
required

对话模型名称

可用选项:
kimi-k2-thinking,
kimi-k2-thinking-turbo
Example:

"kimi-k2-thinking"

messages
object[]
required

对话消息列表,支持多轮对话和多模态输入

Minimum length: 1
stream
boolean
default:false

是否以流式方式返回响应

  • true: 流式返回,逐块实时返回内容
  • false: 等待完整响应后一次性返回
Example:

false

max_tokens
integer

生成回复的最大 token 数量

说明:

  • 此值过小可能导致回复被截断
  • 如果到生成了最大 token 数个结果仍然没有结束,finish_reason 会是 "length",否则会是 "stop"
Required range: x >= 1
Example:

2000

temperature
number
default:1

采样温度,控制输出的随机性

说明:

  • 较低值(如 0.2): 更确定、更聚焦的输出
  • 较高值(如 1.5): 更随机、更有创意的输出
  • kimi-k2-thinking 系列模型建议设置为 1.0
Required range: 0 <= x <= 2
Example:

1

top_p
number
default:1

核采样(Nucleus Sampling)参数

说明:

  • 控制从累积概率前多少的token中采样
  • 例如 0.9 表示从累积概率达到90%的token中选择
  • 默认值: 1.0(考虑所有token)

建议: 不要同时调整 temperature 和 top_p

Required range: 0 <= x <= 1
Example:

0.9

top_k
integer

Top-K 采样参数

说明:

  • 例如 10 表示限制每次采样时只考虑概率最高的 10 个 token
  • 较小的值会使输出更加聚焦
  • 默认不限制
Required range: x >= 1
Example:

40

n
integer
default:1

为每条输入消息生成多少个结果

说明:

  • 默认为 1,不得大于 5
  • 当 temperature 非常小靠近 0 的时候,只能返回 1 个结果
Required range: 1 <= x <= 5
Example:

1

presence_penalty
number
default:0

存在惩罚,介于 -2.0 到 2.0 之间的数字

说明:

  • 正值会根据新生成的词汇是否出现在文本中来进行惩罚,增加模型讨论新话题的可能性
Required range: -2 <= x <= 2
Example:

0

frequency_penalty
number
default:0

频率惩罚,介于 -2.0 到 2.0 之间的数字

说明:

  • 正值会根据新生成的词汇在文本中现有的频率来进行惩罚,减少模型一字不差重复同样话语的可能性
Required range: -2 <= x <= 2
Example:

0

response_format
object

响应格式设置

说明:

  • 设置为 {"type": "json_object"} 可启用 JSON 模式,从而保证模型生成的信息是有效的 JSON
  • 当你将 response_format 设置为 {"type": "json_object"} 时,你需要在 prompt 中明确地引导模型输出 JSON 格式的内容
  • 默认为 {"type": "text"}
  • 注意: 请勿混用 partial mode 和 response_format=json_object
stop

停止词,当全匹配这个(组)词后会停止输出

说明:

  • 这个(组)词本身不会输出
  • 最多不能超过 5 个字符串,每个字符串不得超过 32 字节 单个停止词
tools
object[]

工具列表,用于 Tool Use 或 Function Calling

说明:

  • 工具列表,每个工具必须包括一个类型
  • 在 function 结构体中需要包括 name、description 和 parameters
  • tools 的 function 个数目前不得超过 128 个
Maximum length: 128

Response

对话生成成功

id
string

对话完成的唯一标识符

Example:

"cmpl-04ea926191a14749b7f2c7a48a68abc6"

model
string

实际使用的模型名称

Example:

"kimi-k2-thinking"

object
enum<string>

响应类型

可用选项:
chat.completion
Example:

"chat.completion"

created
integer

创建时间戳

Example:

1698999496

choices
object[]

对话生成的选择列表

usage
object

Token 使用统计信息