能力 | | Chat API | Responses API |
文本生成 | | | |
视觉理解 | | | |
结构化输出 | | beta阶段 | beta阶段 |
工具调用 | 函数调用 Function Calling | | |
| 联网搜索 Web Search | | |
| 图像处理 Image Process | | |
| 私域知识库搜索 Knowledge Search | | |
| 云部署 MCP | | |
上下文缓存 | | | 250615之后的模型版本支持 |
Chat API | Responses API |
输入示例 import os from arkruntime import Ark client = Ark( base_url="https://ark.cn-beijing.volces.com/api/v3", api_key=os.getenv('ARK_API_KEY'), ) completion = client.chat.completions.create( model = "doubao-seed-2-1-pro-260628", messages=[ {"role": "user", "content": "Hello."}, ], ) print(completion) | 输入示例 import os from arkruntime import Ark client = Ark( base_url='https://ark.cn-beijing.volces.com/api/v3', api_key=os.getenv('ARK_API_KEY'), ) response = client.responses.create( model="doubao-seed-2-1-pro-260628", input="Hello.", ) print(response) |
输出示例 { "choices": [ { "finish_reason": "stop", "index": 0, "logprobs": null, "message": { "content": "Hello! How can I assist you today? Whether you have a question you'd like answered, want to chat about something that's on your mind, or need help with a specific task, feel free to share—I'm here to help. 😊", "reasoning_content": "\nGot it, let's see. The user just said \"Hello.\" I need to respond in a friendly way. Since the system prompt mentions I'm an AI assistant who can answer questions, chat, and provide information, I should keep it open-ended to encourage them to share what they need help with. Maybe something like \"Hello! How can I assist you today? Whether you have a question, want to chat about something, or need help with a task, feel free to let me know.\" That sounds natural and covers the points from the system prompt.", "role": "assistant" } } ], "created": 1765193367, "id": "0217651933631536335e3dfd75940b9979797202ce7ea2a894823", "model": "doubao-seed-2-1-pro-260628", "service_tier": "default", "object": "chat.completion", "usage": { "completion_tokens": 164, "prompt_tokens": 35, "total_tokens": 199, "prompt_tokens_details": { "cached_tokens": 0 }, "completion_tokens_details": { "reasoning_tokens": 114 } } } | 输出示例 { "created_at": 1765193461, "id": "resp_0217651934613099e1bacc68b98f823c2af95ea68bff0aec36f83", "max_output_tokens": 32768, "model": "doubao-seed-2-1-pro-260628", "object": "response", "output": [ { "id": "rs_02176519346192100000000000000000000ffffac15322033925d", "type": "reasoning", "summary": [ { "type": "summary_text", "text": "\nGot it, let's see. The user said \"hello.\" First, I need to respond in a friendly way. Since the system prompt mentions being a helpful assistant, I should greet back and maybe invite them to ask whatever they need help with. Let me make it natural. Like, \"Hello! How can I assist you today?\" That's simple and open-ended. Yeah, that works." } ], "status": "completed" }, { "type": "message", "role": "assistant", "content": [ { "type": "output_text", "text": "Hello! How can I assist you today? Whether you have a question, need help with a task, or just want to chat, feel free to let me know. 😊" } ], "status": "completed", "id": "msg_02176519346378200000000000000000000ffffac153220cfab51" } ], "service_tier": "default", "status": "completed", "usage": { "input_tokens": 35, "output_tokens": 118, "total_tokens": 153, "input_tokens_details": { "cached_tokens": 0 }, "output_tokens_details": { "reasoning_tokens": 82 } }, "caching": { "type": "disabled" }, "store": true, "expire_at": 1765452661 } |
Chat API | Responses API |
import os from arkruntime import Ark client = Ark( base_url="https://ark.cn-beijing.volces.com/api/v3", api_key=os.getenv('ARK_API_KEY'), ) completion = client.chat.completions.create( # Replace with Model ID model = "doubao-seed-2-1-pro-260628", messages=[ {"role": "user","content": "Hi,帮我讲个笑话。"}, {"role": "assistant","content":"我把洗面奶当牙膏挤,刷完牙才发现味道不对。"}, {"role": "user","content": "这个笑话的笑点在哪?"} ] ) print(completion.choices[0].message.content) | import os from arkruntime import Ark client = Ark( base_url='https://ark.cn-beijing.volces.com/api/v3', api_key=os.getenv('ARK_API_KEY'), ) # Create the first-round conversation request response = client.responses.create( model="doubao-seed-2-1-pro-260628", input=[{"role": "user", "content": "Hi,帮我讲个笑话。"}], ) print(response) # Create the second-round conversation request second_response = client.responses.create( model="doubao-seed-2-1-pro-260628", previous_response_id=response.id, input=[{"role": "user", "content": "这个笑话的笑点在哪?"}], ) print(second_response) |
Chat API | Responses API |
import os from arkruntime import Ark client = Ark( base_url="https://ark.cn-beijing.volces.com/api/v3", api_key=os.getenv('ARK_API_KEY'), ) completion = client.chat.completions.create( model = "doubao-seed-2-1-pro-260915", messages=[ {"role": "user", "content": "常见的十字花科植物有哪些?json输出"}, ], response_format={"type":"json_object"}, thinking={"type": "disabled"},# 不使用深度思考能力 ) print(completion.choices[0].message.content) | import os from arkruntime import Ark client = Ark( base_url='https://ark.cn-beijing.volces.com/api/v3', api_key=os.getenv('ARK_API_KEY'), ) response = client.responses.create( model="doubao-seed-2-1-pro-260915", input=[ {"role": "user", "content": "常见的十字花科植物有哪些?json输出"}, ], text={"format":{"type": "json_object"}}, thinking={"type": "disabled"},# 不使用深度思考能力 ) print(response) |
Chat API | Responses API |
import os from arkruntime import Ark client = Ark( base_url="https://ark.cn-beijing.volces.com/api/v3", api_key=os.getenv('ARK_API_KEY'), ) completion = client.chat.completions.create( model = "doubao-seed-2-1-pro-260628", messages=[ {"role": "system", "content": "你是 AI 人工智能助手"}, {"role": "user", "content": "常见的十字花科植物有哪些?"}, ], max_completion_tokens = 1024, ) print(completion.choices[0].message.content) | import os from arkruntime import Ark client = Ark( base_url='https://ark.cn-beijing.volces.com/api/v3', api_key=os.getenv('ARK_API_KEY'), ) response = client.responses.create( model="doubao-seed-2-1-pro-260628", input=[ {"role": "system", "content": "你是 AI 人工智能助手"}, {"role": "user", "content": "常见的十字花科植物有哪些?"}, ], max_output_tokens = 1024, ) print(response) |
Context API | Responses API |
import datetime import os from arkruntime import Ark client = Ark( base_url='https://ark.cn-beijing.volces.com/api/v3', api_key=os.environ.get("ARK_API_KEY"), ) response = client.context.create( model="<YOUR_ENDPOINT_ID>", mode="session", messages=[ {"role": "system", "content": "你是李雷"}, ], ttl=datetime.timedelta(minutes=60), ) print(response) print("----- chat round 1 -----") first_response = client.context.completions.create( context_id=response.id, model="<YOUR_ENDPOINT_ID>", messages=[ {"role": "user", "content": "我是方方"}, ] ) print(first_response.choices[0].message.content) print("----- chat round 2 -----") second_response = client.context.completions.create( context_id=response.id, model="<YOUR_ENDPOINT_ID>", messages=[ {"role": "user", "content": "你是谁,我是谁?"}, ] ) print(second_response.choices[0].message.content) | import os from arkruntime import Ark client = Ark( base_url='https://ark.cn-beijing.volces.com/api/v3', api_key=os.getenv('ARK_API_KEY'), ) response = client.responses.create( model="doubao-seed-2-1-pro-260628", input=[ {"role": "system", "content": "你是李雷"}, ], caching={"type": "enabled"}, thinking={"type": "disabled"}, ) print(response.output[0].content[0].text) print("----- chat round 1 -----") first_response = client.responses.create( model="doubao-seed-2-1-pro-260628", previous_response_id=response.id, input=[{"role": "user", "content": "我是方方"}], caching={"type": "enabled"}, thinking={"type": "disabled"}, ) print(first_response.output[0].content[0].text) print("----- chat round 2 -----") second_response = client.responses.create( model="doubao-seed-2-1-pro-260628", previous_response_id=first_response.id, input=[{"role": "user", "content": "你是谁,我是谁?"}], caching={"type": "enabled"}, thinking={"type": "disabled"}, ) print(second_response.output[0].content[0].text) |
Chat API | Responses API |
[ { "type": "function", "function": { "name": "get_weather", "description": "根据城市名称查询该城市当日天气(含温度、天气状况)", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "城市名称,如北京、上海(仅支持国内地级市)" } }, "required": [ "location" ] } } } ] | [ { "type": "function", "name": "get_weather", "description": "根据城市名称查询该城市当日天气(含温度、天气状况)", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "城市名称,如北京、上海(仅支持国内地级市)" } }, "required": [ "location" ] } } ] |