Api
对话补全 (Chat Completions)
创建多轮或单轮模型对话响应,支持流式传输、思考链 (Reasoning Content) 与工具调用。
接口定义
POST https://token.astrumflow.com/v1/chat/completions
Content-Type: application/json
Authorization: Bearer sk-your-astrumflow-token-key📥 请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型名称,如 GPT-5.6-sol、GPT-5.6-terra、GPT-5.6-luna。 |
messages | array | 是 | 对话上下文列表,包含 role (system, user, assistant, tool) 与 content。 |
stream | boolean | 否 | 是否启用流式输出(SSE)。开启后以数据块持续返回,大幅降低首字等待延迟。 |
temperature | number | 否 | 采样温度,介于 0.0 到 2.0。数值越低越确定严谨,越高越具创造性。默认 1.0。 |
top_p | number | 否 | 核采样阈值。通常建议与 temperature 仅调整其中之一。 |
max_tokens | integer | 否 | 最大输出 Token 数。 |
tools | array | 否 | 模型可调用的函数/工具列表(Function Calling)。 |
tool_choice | string/object | 否 | 控制模型是否必须调用特定工具。默认 auto。 |
response_format | object | 否 | 强制结构化输出,如 {"type": "json_object"}。 |
💻 请求与调用示例
1. 标准非流式请求
curl https://token.astrumflow.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-astrumflow-token-key" \
-d '{
"model": "GPT-5.6-terra",
"messages": [
{"role": "system", "content": "你是一位资深架构师。"},
{"role": "user", "content": "解释一下什么是 RESTful API?"}
],
"temperature": 0.7
}'标准响应示例 (JSON)
{
"id": "chatcmpl-9Xy78z...",
"object": "chat.completion",
"created": 1723650000,
"model": "GPT-5.6-terra",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "RESTful API 是一种基于 REST(Representational State Transfer)架构风格设计的网络接口..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 28,
"completion_tokens": 150,
"total_tokens": 178
}
}⚡ 2. 流式输出 (Streaming Response)
设置 "stream": true,模型将以 Server-Sent Events (SSE) 形式逐步返回数据:
from openai import OpenAI
client = OpenAI(
base_url="https://token.astrumflow.com/v1",
api_key="sk-your-astrumflow-token-key"
)
stream = client.chat.completions.create(
model="GPT-5.6-sol",
messages=[
{"role": "user", "content": "写一段 Python 代码实现高性能快速排序。"}
],
stream=True
)
for chunk in stream:
content = chunk.choices[0].delta.content or ""
print(content, end="", flush=True)🧠 3. 深度思考模型 (Reasoning Content / Thinking)
对于 GPT-5.6-sol 等具备深度推理思考链的模型,疾旋Token 在返回结果中支持标准的 reasoning_content 思考过程透传。
# 提取 GPT-5.6-sol 深度思考链
response = client.chat.completions.create(
model="GPT-5.6-sol",
messages=[{"role": "user", "content": "9.11 和 9.8 哪个数更大?请给出严密数学推导。"}]
)
message = response.choices[0].message
# 思考过程
if hasattr(message, 'reasoning_content') and message.reasoning_content:
print("【深度思考过程】:")
print(message.reasoning_content)
# 最终回答
print("\n【最终回答】:")
print(message.content)👁️ 4. 多模态识图 (Vision)
支持向模型发送图片进行视觉理解与分析:
response = client.chat.completions.create(
model="GPT-5.6-sol",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "请详细描述并分析这张架构图。"},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
}
}
]
}
]
)
print(response.choices[0].message.content)