✅ 服务运行正常
Cursor2API已成功启动并运行中
📍 服务地址
http://localhost:8002
🔑 API密钥
0000 (默认)
🎯 兼容性
OpenAI API 标准
🌊 流式支持
支持 SSE 流式响应
🧰 Tool Calls
支持 tools / tool_choice / tool_calls
🧠 Thinking
自动暴露 -thinking 模型(thinking 不对外透出)
🚀 快速开始
# 获取模型列表
curl -H "Authorization: Bearer 0000" http://localhost:8002/v1/models
非流式聊天 (Non-Streaming)
curl -X POST http://localhost:8002/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 0000" \
-d '{
"model": "claude-sonnet-4.6",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": false
}'
流式聊天 (Streaming)
curl -X POST http://localhost:8002/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 0000" \
-d '{
"model": "claude-sonnet-4.6",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'
工具调用 (Tool Calls)
curl -X POST http://localhost:8002/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 0000" \
-d '{
"model": "claude-sonnet-4.6",
"messages": [{"role": "user", "content": "What is 2+2? Use the calculator tool."}],
"tools": [
{
"type": "function",
"function": {
"name": "calculator",
"description": "Evaluate a simple arithmetic expression.",
"parameters": {
"type": "object",
"properties": {
"expression": {"type": "string"}
},
"required": ["expression"]
}
}
}
],
"tool_choice": {"type": "function", "function": {"name": "calculator"}},
"stream": false
}'
Kilo Code 兼容(可选)
# 当上层强制“必须用工具”时,可在 .env 开启
KILO_TOOL_STRICT=true
# 非流式请求:若要求用工具但本轮未产出 tool_calls,会自动重试 1 次(流式不重试)
🤖 支持的AI模型
点击模型卡片可查看详细信息和使用示例
claude-sonnet-4.6
Anthropic Claude
claude-sonnet-4.6-thinking
Anthropic Claude + Thinking
📡 API端点文档
GET
/v1/models
获取所有可用的AI模型列表
curl -H "Authorization: Bearer 0000" http://localhost:8002/v1/models
POST
/v1/chat/completions
创建聊天完成请求,支持流式、非流式和 OpenAI 兼容 tool_calls
curl -X POST http://localhost:8002/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 0000" \
-d '{
"model": "claude-sonnet-4.6",
"messages": [
{"role": "user", "content": "你好"}
],
"stream": false
}'
说明:当响应包含工具调用时,非流式会返回 message.tool_calls 且 finish_reason="tool_calls";
流式会在 delta.tool_calls 中输出,并在最后一个 chunk 以 finish_reason="tool_calls" 收尾。
GET
/health
健康检查端点
curl http://localhost:8002/health