Appearance
Kimi 模型接口文档
兼容 OpenAI Chat Completions 接口,支持 Kimi(Moonshot AI)系列模型的普通消息、多模态输入与流式输出。
Base URL:https://api.agentpivot.net/v1/
登录平台
- Url:https://agentpivot.net/
- token:平台创建
- api-key:平台创建
接口概览
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /chat/completions | Kimi 对话接口(Chat Completions) |
| POST | /responses | Kimi 响应式接口(Responses,OpenAI 兼容) |
鉴权
使用 API Key:
| Header | 说明 |
|---|---|
x-api-key: <API_KEY> | 使用 API Key |
示例:
bash
curl -X POST "https://api.agentpivot.net/v1/chat/completions" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kimi-k2.6",
"messages": [{
"role": "user",
"content": "你好"
}]
}'支持模型
| 模型名称 | 说明 |
|---|---|
| kimi-k3 | 旗舰模型,2.8 万亿参数,1M token 上下文,原生视觉理解,面向长程编程与端到端知识工作 |
| kimi-k2.7-code-highspeed | 面向代码场景的 Coding 模型,256K 上下文,文本/图片/视频输入,思考模式,更高输出速度 |
| kimi-k2.6 | 通用能力强,256K 上下文,文本/图片/视频输入,思考与非思考模式,适合通用对话、Agent、视觉理解与复杂推理 |
POST /chat/completions
请求
- Content-Type:
application/json
Body
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型名称 |
messages | array | 是 | 对话消息列表 |
stream | boolean | 否 | 是否启用流式输出 |
max_tokens | number | 否 | 最大输出 Token 数 |
temperature | number | 否 | 采样温度 |
top_p | number | 否 | Top-P 采样 |
reasoning_effort | string | 否 | 推理强度,kimi-k3 支持 low / high / max(默认 max) |
messages
| 字段 | 类型 | 说明 |
|---|---|---|
role | string | system | user | assistant | tool |
content | string | array | 消息内容;支持纯文本字符串,或用于多模态输入的对象数组 |
content 多模态输入
content 支持对象数组形式,数组元素通过 type 区分:
| type | 说明 |
|---|---|
text | 文本内容 |
image_url | 图片(base64 data URL 或文件引用) |
video_url | 视频(base64 data URL 或文件引用,kimi-k3 / kimi-k2.6 / kimi-k2.7-code 支持) |
请求示例
1. kimi-k3(旗舰,配置推理强度)
bash
#!/usr/bin/env bash
API_KEY="YOUR_API_KEY"
curl -s https://api.agentpivot.net/v1/chat/completions \
-H "Content-Type: application/json" \
-H "x-api-key: ${API_KEY}" \
-d '{
"model": "kimi-k3",
"messages": [
{
"role": "user",
"content": "分析未来五年 AI 发展趋势"
}
],
"reasoning_effort": "high",
"stream": false
}' | jq2. kimi-k2.6(通用对话)
bash
#!/usr/bin/env bash
API_KEY="YOUR_API_KEY"
curl -s https://api.agentpivot.net/v1/chat/completions \
-H "Content-Type: application/json" \
-H "x-api-key: ${API_KEY}" \
-d '{
"model": "kimi-k2.6",
"messages": [
{
"role": "user",
"content": "你好"
}
],
"stream": false
}' | jq3. kimi-k2.7-code-highspeed(代码生成)
bash
#!/usr/bin/env bash
API_KEY="YOUR_API_KEY"
curl -s https://api.agentpivot.net/v1/chat/completions \
-H "Content-Type: application/json" \
-H "x-api-key: ${API_KEY}" \
-d '{
"model": "kimi-k2.7-code-highspeed",
"messages": [
{
"role": "user",
"content": "写一个快速排序的 Python 实现"
}
],
"stream": false
}' | jq4. 多模态输入(图片理解)
bash
#!/usr/bin/env bash
API_KEY="YOUR_API_KEY"
curl -s https://api.agentpivot.net/v1/chat/completions \
-H "Content-Type: application/json" \
-H "x-api-key: ${API_KEY}" \
-d '{
"model": "kimi-k2.6",
"messages": [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
}
},
{
"type": "text",
"text": "请描述这张图片"
}
]
}
],
"stream": false
}' | jq流式输出
kimi-k3
bash
curl -N https://api.agentpivot.net/v1/chat/completions \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"model": "kimi-k3",
"messages": [
{
"role": "user",
"content": "详细解释 Transformer 工作原理"
}
],
"stream": true
}'kimi-k2.6
bash
curl -N https://api.agentpivot.net/v1/chat/completions \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"model": "kimi-k2.6",
"messages": [
{
"role": "user",
"content": "写一个快速排序"
}
],
"stream": true
}'响应示例
json
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1700000000,
"model": "kimi-k2.6",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "你好!我是 Kimi,有什么可以帮你的吗?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 15,
"total_tokens": 27
}
}POST /responses(Responses 接口)
Kimi 同样兼容 OpenAI 的 Responses 接口,面向多轮对话、工具调用与 Agent 场景。与 Chat Completions 相比,请求/响应结构与字段命名不同。
路径:POST /responses
与 /chat/completions 的关键差异
| Chat Completions | Responses |
|---|---|
messages | input(字符串或输入条目列表) |
system 消息放入 messages | instructions(作为第一条 system 消息) |
max_tokens | max_output_tokens |
响应 choices[].message.content | 响应 output[](含 message / function_call 等条目) |
Body(顶层参数)
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型名称 |
input | string | array | 是* | 输入内容(字符串或输入条目列表),input 与 instructions 至少填一个 |
instructions | string | 否 | 系统指令,作为第一条 system 消息 |
stream | boolean | 否 | 是否启用流式输出(SSE) |
temperature | number | 否 | 采样温度 |
top_p | number | 否 | Top-P 采样 |
max_output_tokens | number | 否 | 最大输出 Token 数 |
reasoning_effort | string | 否 | 推理强度(kimi-k3 支持 low / high / max) |
*
input与instructions至少提供一个。
请求示例
bash
curl -s https://api.agentpivot.net/v1/responses \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"model": "kimi-k3",
"instructions": "你是一个严谨的技术顾问。",
"input": "什么是响应式接口?",
"reasoning_effort": "high"
}' | jq流式输出(SSE)
bash
curl -N https://api.agentpivot.net/v1/responses \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"model": "kimi-k2.6",
"instructions": "You are a helpful assistant.",
"input": "写一个快速排序",
"stream": true
}'流式返回为 SSE 事件序列,以 response.completed / response.incomplete / response.failed 结束(没有 data: [DONE])。关键事件:response.created、response.output_text.delta、response.output_text.done、response.completed。
响应示例
json
{
"id": "resp_xxx",
"object": "response",
"created_at": 1700000000,
"status": "completed",
"model": "kimi-k3",
"output": [
{
"type": "message",
"id": "msg_xxx",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "响应式接口(Responses API)是 OpenAI 兼容的新一代接口。",
"annotations": []
}
]
}
],
"usage": {
"input_tokens": 20,
"output_tokens": 25,
"total_tokens": 45,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 8
}
}
}测试脚本
bash
export API_KEY="YOUR_API_KEY"
curl -s https://api.agentpivot.net/v1/chat/completions \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model":"kimi-k2.6",
"messages":[
{
"role":"user",
"content":"介绍一下 Kimi"
}
]
}' | jq