接口

接口参考

Chat Completions 和 Models 两个接口的地址、参数和返回。

鉴权

所有请求都在请求头里带上 Key。Key 在控制台“令牌”里创建,以 sk- 开头。

HTTP 头
Authorization: Bearer sk-你的Key
Content-Type: application/json

POST /chat/completions

对话补全。请求体是 JSON,常用参数如下,其余 OpenAI 参数会原样转给模型,是否生效取决于模型本身。

参数类型说明
modelstring,必填模型 ID,见模型页,例如 deepseek-v4.1-flash-heretic
messagesarray,必填对话消息,每条有 role(system / user / assistant / tool)和 content
streamboolean是否流式返回,默认 false
max_tokensinteger最多生成多少 token
temperaturenumber采样温度,0 到 2
top_pnumber核采样,0 到 1
stopstring 或 array遇到这些字符串就停止生成
tools / tool_choicearray / string工具调用,仅部分模型支持(模型页有“工具调用”标签)
response_formatobject要求输出 JSON,仅部分模型支持
请求示例
curl https://api.geniusrelaygpt.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4.1-flash-heretic",
    "messages": [
      {"role": "system", "content": "你是一个简洁的助手"},
      {"role": "user", "content": "一句话解释什么是 token"}
    ],
    "max_tokens": 200
  }'
返回示例
{
  "id": "chatcmpl-3f9a…",
  "object": "chat.completion",
  "created": 1763000000,
  "model": "deepseek-v4.1-flash-heretic",
  "choices": [{
    "index": 0,
    "message": { "role": "assistant", "content": "token 是模型处理文本的最小单位…" },
    "finish_reason": "stop"
  }],
  "usage": { "prompt_tokens": 24, "completion_tokens": 31, "total_tokens": 55 }
}

usage 里的 token 数就是计费依据。finish_reason 为 length 表示被 max_tokens 截断。

GET /models

返回当前 Key 可以调用的全部模型 ID。

curl
curl https://api.geniusrelaygpt.com/v1/models -H "Authorization: Bearer $API_KEY"