POST https://www.moyu.info/v1/chat/completions-d 参数直接传递中文时,curl 会使用系统码页(GBK)而非 UTF-8 编码,导致中文被识别为乱码。--data-binary @文件 方式发送请求{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "这张图展现了壮美开阔的自然户外场景:前景是宽阔平静的深蓝色湖面,一艘亮橙色的皮划艇漂在水面上;中景是沿着湖岸生长的茂密针叶林,林间笼着薄雾;远景是连绵巍峨、覆着积雪的高大山脉,衬着清朗的淡蓝色天空。",
"reasoning_content": "用户现在问这张图主要展示什么...",
"role": "assistant"
}
}
],
"created": 1782099072,
"id": "021782099058603f74590442eab0123ecdd9df6ba66d3a91c6b19",
"model": "doubao-seed-2-0-pro-260215",
"object": "chat.completion",
"usage": {
"completion_tokens": 442,
"prompt_tokens": 1353,
"total_tokens": 1795,
"prompt_tokens_details": {"cached_tokens": 0},
"completion_tokens_details": {"reasoning_tokens": 313}
}
}| 接口 | content type | 图片字段格式 |
|---|---|---|
/v1/chat/completions | image_url | {"type": "image_url", "image_url": {"url": "图片URL"}} |
/v1/responses | input_image | {"type": "input_image", "image_url": "图片URL"} |
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "这是一段AI生成的延时风格视频,展现了伦敦经典地标场景:画面主体是伊丽莎白塔(大本钟)矗立在泰晤士河畔,时段为晨昏时分,天空覆着有层次感的云层。下方威斯敏斯特桥上车流处于快速运动的延时状态,双向车道车辆川流不息,其中标志性的红色双层巴士格外醒目。",
"reasoning_content": "用户现在需要描述这个AI生成的视频内容...",
"role": "assistant"
}
}
],
"created": 1782100464,
"id": "021782100435589f74590442eab0123ecdd9df6ba66d3a9981cae",
"model": "doubao-seed-2-0-pro-260215",
"object": "chat.completion",
"usage": {
"completion_tokens": 605,
"prompt_tokens": 6390,
"total_tokens": 6995,
"prompt_tokens_details": {"cached_tokens": 0},
"completion_tokens_details": {"reasoning_tokens": 421}
}
}| 接口 | content type | 视频字段格式 |
|---|---|---|
/v1/chat/completions | video_url | {"type": "video_url", "video_url": {"url": "视频URL或Base64"}} |
/v1/responses | input_video | {"type": "input_video", "video_url": "视频URL或Base64", "fps": 1} |
| 方式 | 优点 | 缺点 | 适用场景 |
|---|---|---|---|
| URL 链接 | 请求体小、传输快 | 需要视频可公开访问 | 视频已托管在 CDN/OSS |
| Base64 编码 | 无需公网可访问的 URL | 请求体大(约为原文件 1.33 倍) | 本地 视频文件 |
fps(仅 Responses 接口):视频采样帧率,表示每秒提取的帧数,默认为 1{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "Artificial intelligence is the simulation of human intelligence by machines, particularly computer systems. It encompasses learning, reasoning, problem-solving, perception, and language understanding. AI is revolutionizing industries from healthcare to transportation with its growing capabilities.",
"reasoning_content": "The user is asking for a concise explanation of AI in three sentences...",
"role": "assistant"
}
}
],
"created": 1770776426,
"id": "021770776423638e3a31c433292ba20cb5fbeea5c08b17662cb9b",
"model": "doubao-seed-1-8-251228",
"service_tier": "default",
"object": "chat.completion",
"usage": {
"completion_tokens": 116,
"prompt_tokens": 60,
"total_tokens": 176,
"prompt_tokens_details": {
"cached_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 76
}
}
}| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | 是 | 模型名称,如 doubao-seed-1-8-251228 |
| messages | array | 是 | 对话消息列表 |
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| role | string | 是 | 角色:user(用户) 或 assistant(助手) |
| content | string | 是 | 消息内容 |
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| temperature | float | 否 | 1.0 | 控制输出的随机性,范围 0-2 |
| top_p | float | 否 | 1.0 | 核采样参数,范围 0-1 |
| max_tokens | integer | 否 | - | 生成的最大token数量 |
| stream | boolean | 否 | false | 是否流式返回 |
| presence_penalty | float | 否 | 0 | 存在惩罚,范围 -2.0 到 2.0 |
| frequency_penalty | float | 否 | 0 | 频率惩罚,范围 -2.0 到 2.0 |
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | 请求的唯一标识符 |
| object | string | 对象类型,固定为 "chat.completion" |
| created | integer | 创建时间戳 |
| model | string | 使用的模型名称 |
| choices | array | 生成的回复列表 |
| choices[].message.role | string | 回复角色,为 "assistant" |
| choices[].message.content | string | 生成的文本内容 |
| choices[].message.reasoning_content | string | 推理过程内容(如果模型支持) |
| choices[].finish_reason | string | 结束原因:stop(正常结束)、length(达到长度限制) |
| usage | object | token 使用情况统计 |
| usage.prompt_tokens | integer | 输入消息使用的 token 数 |
| usage.completion_tokens | integer | 生成内容使用的 token 数 |
| usage.total_tokens | integer | 总 token 数 |
| usage.prompt_tokens_details | object | 输入 token 详情 |
| usage.prompt_tokens_details.cached_tokens | integer | 缓存命中的输入 token 数(未命中缓存时为 0) |
| usage.completion_tokens_details | object | 输出 token 详情 |
| usage.completion_tokens_details.reasoning_tokens | integer | 推理过程消耗的 token 数(不支持推理的模型为 0) |
-d 参数使用系统码页(GBK/CP936)编码中文,而非 UTF-8。这会导致:--trace 查看实际发送的字节:c4 e3 ba c3)而非 UTF-8(e4 bd a0 e5 a5 bd),则确认是编码问题。chcp 65001| 模型名称 | 说明 | 多模态 | 支持语言 |
|---|---|---|---|
| doubao-seed-1-8-251228 | 豆包推理模型 | 文本 | 英文(中文有编码问题) |
| doubao-seed-2-0-pro-260215 | 豆包多模态推理模型 | 文本、图片、视频输入 | 中文、英文 |
--data-binary @文件 方式或编程语言调用。