跳转到主要内容

5 分钟接入

从零开始,用最少的代码跑通你的第一次对话请求。

Step 1: 获取 API Key

登录 Reeve 控制台,在 API Keys 页面点击「创建密钥」。

# 你的密钥长这样 reeve_sk_a1b2c3d4e5f6g7h8i9j0...

安全提示

  • 密钥只在创建时显示一次,请妥善保存
  • 如密钥泄露,请立即在控制台吊销
  • 不要将密钥提交到 Git 仓库或前端代码中
  • 建议使用环境变量 REEVE_API_KEY 存储

Step 2: 发送第一个请求

使用 cURL 或任意 HTTP 客户端:

bash
curl https://api.reeve.ai/v1/chat/completions \
  -H "Authorization: Bearer reeve_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v3",
    "messages": [
      { "role": "user", "content": "你好,Reeve!" }
    ]
  }'

Step 3: 解析响应

成功后你将收到如下 JSON 响应:

json
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1700000000,
  "model": "deepseek-v3",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "你好!我是 Reeve,很高兴为你服务!"
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 18,
    "total_tokens": 30
  }
}

Step 4: 开启流式输出

添加 "stream": true 即可获得打字机效果:

bash
curl https://api.reeve.ai/v1/chat/completions \
  -H "Authorization: Bearer reeve_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v3",
    "messages": [{ "role": "user", "content": "Hello" }],
    "stream": true
  }'

参见 了解完整 SSE 事件格式。