端点
https://www.focusapi.cn/v1
请求头
请求体(常用字段)
最小示例
流式输出
设置"stream": true 后,响应为 Server-Sent Events (SSE),每行以 data: 开头。
Python SDK 示例:
响应(非流式)
成功时 HTTP 200,JSON 结构兼容 OpenAI,例如:usage 用于计费参考,具体扣费规则见 计费说明。
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
FocusAPI Chat Completions 附录参考:POST /v1/chat/completions 端点、请求字段、流式输出和响应结构。
POST /v1/chat/completions
https://www.focusapi.cn/v1
| 头 | 必填 | 说明 |
|---|---|---|
Authorization | 是 | Bearer sk-your-api-key |
Content-Type | 是 | application/json |
| 字段 | 类型 | 说明 |
|---|---|---|
model | string | 模型 ID,见模型广场 |
messages | array | 对话消息列表,role 为 system / user / assistant |
stream | boolean | true 时以 SSE 流式返回 |
temperature | number | 采样温度,可选 |
max_tokens | integer | 最大生成 token 数,可选 |
{
"model": "gpt-4o-mini",
"messages": [
{ "role": "user", "content": "你好" }
]
}
"stream": true 后,响应为 Server-Sent Events (SSE),每行以 data: 开头。
Python SDK 示例:
stream = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "你好"}],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "..." },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 20,
"total_tokens": 30
}
}
usage 用于计费参考,具体扣费规则见 计费说明。
