Seed 文本对话
Seed 是字节跳动推出的大语言模型系列,具备强大的中文理解与生成能力。接口完全兼容 OpenAI 格式,可零成本迁移现有 OpenAI 应用。
端点
Seed 提供两种兼容端点,调用方式完全一致,可任选其一:
- OpenAI 兼容:
POST $URL/v1/chat/completions - 火山方舟原厂:
POST $URL/api/v3/chat/completions
使用 OpenAI SDK 时,base_url 设为 $URL/v1 或 $URL/api/v3 均可。
支持模型
| 模型 | 定位 |
|---|---|
seed-2.0-pro | 旗舰版,综合能力最强 |
seed-2.0-lite | 轻量版,高性价比 |
seed-2.0-mini | 迷你版,极致速度 |
seed-2.1-pro | 2.1 旗舰版,推理与长文本增强 |
seed-2.1-turbo | 2.1 高速版,低延迟 |
以上模型名均可加
doubao-前缀使用(如doubao-seed-2.0-pro),效果完全一致。
更多历史版本见控制台「模型广场」。
主要参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 上述模型名称 |
messages | array | 是 | 对话消息列表,每条含 role(system/user/assistant)与 content |
stream | boolean | 否 | 是否流式返回,默认 false |
temperature | number | 否 | 采样温度 0~2,越大越随机,默认 1 |
top_p | number | 否 | 核采样概率 0~1,默认 1 |
max_tokens | integer | 否 | 最大生成 token 数 |
presence_penalty | number | 否 | 重复惩罚 −2~2,默认 0 |
frequency_penalty | number | 否 | 词频惩罚 −2~2,默认 0 |
stop | string / array | 否 | 生成停止符 |
response_format | object | 否 | 指定输出格式(如 {"type":"json_object"}) |
请求示例
bash
curl $URL/v1/chat/completions \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "seed-2.0-pro",
"messages": [
{"role": "user", "content": "用一句话解释量子计算"}
]
}'python
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="$URL/v1")
resp = client.chat.completions.create(
model="seed-2.0-pro",
messages=[{"role": "user", "content": "用一句话解释量子计算"}],
)
print(resp.choices[0].message.content)ts
import OpenAI from 'openai'
const client = new OpenAI({
apiKey: process.env.YOUR_API_KEY,
baseURL: '$URL/v1',
})
const resp = await client.chat.completions.create({
model: 'seed-2.0-pro',
messages: [{ role: 'user', content: '用一句话解释量子计算' }],
})
console.log(resp.choices[0].message.content)响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 本次请求唯一 ID |
object | string | 固定为 chat.completion |
created | integer | 创建时间戳(秒) |
model | string | 实际使用的模型 |
choices | array | 候选回复列表 |
choices[].index | integer | 候选序号 |
choices[].message | object | 回复消息对象 |
choices[].message.role | string | 固定为 assistant |
choices[].message.content | string | 回复文本内容 |
choices[].finish_reason | string | 结束原因(stop/length/content_filter 等) |
usage | object | token 用量统计 |
usage.prompt_tokens | integer | 输入 token 数 |
usage.completion_tokens | integer | 输出 token 数 |
usage.total_tokens | integer | 总 token 数 |
响应示例
json
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1700000000,
"model": "seed-2.0-pro",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "量子计算利用量子比特的叠加与纠缠并行处理信息,在特定问题上远快于经典计算机。"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 38,
"total_tokens": 50
}
}