curl --request POST \
--url https://api.aihubmax.com/v1/llm/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "count 1 to 3"
}
],
"stream": false,
"max_tokens": 32
}
'{
"id": "task-llm-1776874481-rj6bs3yb",
"object": "llm.generation.task",
"type": "llm",
"model": "gpt-5.5",
"status": "pending",
"progress": 0,
"created": 1776874481,
"stream": null,
"results": null,
"error": null
}混合理解
使用返回的任务 ID 进行查询 获取最终结果。
curl --request POST \
--url https://api.aihubmax.com/v1/llm/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "count 1 to 3"
}
],
"stream": false,
"max_tokens": 32
}
'{
"id": "task-llm-1776874481-rj6bs3yb",
"object": "llm.generation.task",
"type": "llm",
"model": "gpt-5.5",
"status": "pending",
"progress": 0,
"created": 1776874481,
"stream": null,
"results": null,
"error": null
}授权
所有接口均需要使用 Bearer Token 进行认证。在请求头中添加:
Authorization: Bearer YOUR_API_KEY
YOUR_API_KEY 为 API Token(sk-... 格式)。
请求体
messages[] 形态的请求体(OpenAI Chat 兼容)。除下列字段外,其他 OpenAI 兼容参数(temperature、top_p、stop、frequency_penalty 等)按 OpenAI Chat 规范使用。
OpenAI Chat 格式消息数组。messages[*].content 可为 string 或 array;array 元素 type ∈ {text, image_url, video_url, audio_url, file_url}。模型不支持的 type 返 422 model_not_support_capability。
典型 content 形态示例:
- 纯 text(string content,最简形式):
[{"role": "user", "content": "count 1 to 3"}]
- 纯 text(array content,与多模态混用时统一格式):
[{"role": "user", "content": [{"type": "text", "text": "count 1 to 3"}]}]
- text + 图片:
[{"role": "user", "content": [
{"type": "text", "text": "describe this image"},
{"type": "image_url", "image_url": {"url": "https://example.com/x.png"}}
]}]
- text + 视频:
[{"role": "user", "content": [
{"type": "text", "text": "summarize this video"},
{"type": "video_url", "video_url": {"url": "https://example.com/clip.mp4"}}
]}]
- text + 文件:
[{"role": "user", "content": [
{"type": "text", "text": "extract key points"},
{"type": "file_url", "file_url": {"url": "https://example.com/doc.pdf"}}
]}]
- 多轮对话(system + 多轮 user/assistant):
[
{"role": "system", "content": "You are a terse assistant."},
{"role": "user", "content": "1+1?"},
{"role": "assistant", "content": "2"},
{"role": "user", "content": "3+3?"}
]
- 全类型附件混合(单条 user 消息内含
image_url/video_url/audio_url/file_url各 2 个):
[{"role": "user", "content": [
{"type": "text", "text": "汇总下列图片、视频、音频和文档的核心信息"},
{"type": "image_url", "image_url": {"url": "https://example.com/image-1.png"}},
{"type": "image_url", "image_url": {"url": "https://example.com/image-2.jpg"}},
{"type": "video_url", "video_url": {"url": "https://example.com/clip-1.mp4"}},
{"type": "video_url", "video_url": {"url": "https://example.com/clip-2.mp4"}},
{"type": "audio_url", "audio_url": {"url": "https://example.com/audio-1.mp3"}},
{"type": "audio_url", "audio_url": {"url": "https://example.com/audio-2.wav"}},
{"type": "file_url", "file_url": {"url": "https://example.com/doc-1.pdf"}},
{"type": "file_url", "file_url": {"url": "https://example.com/doc-2.docx"}}
]}]
内联 base64(仅异步模式,sync 省略或为 false):image_url / video_url / audio_url / file_url 四种块中,值为 {"url": ...} 对象形态的内联 base64(data: URI,或 4096 个以上编码字符且解码内容命中已知媒体签名的裸 base64),会在请求入库与提交上游之前上传文件存储并替换为 URL,不以 base64 原文入库;更短的裸 base64、或签名不可识别的内容按原样透传,也不做体积校验。上限只作用于内联 base64 项(公网 http(s) URL 不受限):单项解码后 ≤ 5 MB、单数组内联 ≤ 5 项、单请求合计 ≤ 10 MB、单请求内联总数 ≤ 20 项。data: 前缀格式非法或 payload 解码为 0 字节返回 422,超限同样返回 422,请改用 /v1/files/upload 上传后传 URL。
sync: true 时请求不写任务记录,以上均不适用:内联 base64 原样提交上游,不做任何体积或数量校验。
不在覆盖范围内的形态:input_audio.data / file.file_data,以及 {"type":"image_url","image_url":"data:..."} 字符串直挂形态(值不是 {"url": ...} 对象)——这些内联 base64 按原样透传。
Show child attributes
Show child attributes
[
{ "role": "user", "content": "count 1 to 3" }
]
是否流式。
行为差异:
| 值 | Submit 响应 stream 字段 | SSE 端点 |
|---|---|---|
false | null | 不可用 |
true | {"url": "/v1/llm/generations/{task_id}/stream"} | 可用;同时 task.data 累积完整响应 |
false
生成 token 上限。家族级约束:claude-* 必填;gpt-* 通常 ≥ 16;gemini-* 可选。
64
采样温度。
nucleus sampling。
停止序列。
响应
任务已创建
Submit 响应,对齐统一任务标准形状。results / error 在 submit 阶段固定为 null,任务完成/失败后通过 GET /v1/tasks/{task_id} 返回
任务 ID,格式 task-llm-{timestamp}-{8random}。用于 GET /v1/tasks/{task_id} 查询或 GET /v1/llm/generations/{task_id}/stream 订阅 SSE
"task-llm-1776874565-yq3szvcu"
对象类型,固定 llm.generation.task
llm.generation.task "llm.generation.task"
媒体类型,固定 llm
llm "llm"
客户端提交的模型名(原样回显)
"claude-opus-4-7"
任务状态,submit 阶段固定 pending
pending "pending"
进度 0-100,submit 阶段固定 0
0
创建时间(Unix 秒)
1776874565
stream=true 时返回 {url: ...};stream=false 时为 null。客户端据此决定是否连接 SSE
Show child attributes
Show child attributes
submit 阶段固定 null;任务完成后通过 GET /v1/tasks/{task_id} 获取,results[0] 为完整 OpenAI ChatCompletion 响应。
已知限制:thinking 模型的推理内容(reasoning_content)仅在 SSE 流的 delta 中出现,不累积到 results[0].message.content
null
submit 阶段固定 null;任务失败时通过 GET /v1/tasks/{task_id} 返回
null