接口
接口参考
Chat Completions 和 Models 两个接口的地址、参数和返回。
鉴权
所有请求都在请求头里带上 Key。Key 在控制台“令牌”里创建,以 sk- 开头。
Authorization: Bearer sk-你的Key
Content-Type: application/jsonPOST /chat/completions
对话补全。请求体是 JSON,常用参数如下,其余 OpenAI 参数会原样转给模型,是否生效取决于模型本身。
| 参数 | 类型 | 说明 |
|---|---|---|
model | string,必填 | 模型 ID,见模型页,例如 deepseek-v4.1-flash-heretic |
messages | array,必填 | 对话消息,每条有 role(system / user / assistant / tool)和 content |
stream | boolean | 是否流式返回,默认 false |
max_tokens | integer | 最多生成多少 token |
temperature | number | 采样温度,0 到 2 |
top_p | number | 核采样,0 到 1 |
stop | string 或 array | 遇到这些字符串就停止生成 |
tools / tool_choice | array / string | 工具调用,仅部分模型支持(模型页有“工具调用”标签) |
response_format | object | 要求输出 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 https://api.geniusrelaygpt.com/v1/models -H "Authorization: Bearer $API_KEY"