Text
GPT-6.2 Sol
使用 GPT-6.2 Sol 搭配 OpenAI Responses 和 Chat Completions 格式。包含 SDK 範例、結構化輸出、函式呼叫和串流。
日常寫程式和代理工作流程可使用 gpt-6.2-sol。將 OpenAI SDK 的基礎 URL 設為 https://api.seedrouter.ai/v1,並提供你的 SeedRouter API 金鑰。
模型與限制
| 屬性 | GPT-6.2 Sol |
|---|---|
| 請求模型 ID | gpt-6.2-sol |
| 輸入與輸出 | 輸入文字與圖片,輸出文字 |
| 上下文視窗 | 1,050,000 個 token |
| 最大輸入量 | 922,000 個 token |
| 最大輸出量 | 128,000 個 token,包含推理內容 |
| 知識截止日期 | 2026 年 6 月 1 日 |
上下文視窗涵蓋輸入和輸出的總量。設定輸出上限時,請預留足夠空間給推理內容和可見答案。目前每個 token 的費率和長上下文定價請見模型頁面。
Responses
安裝 Python openai 套件,並在環境中設定 SEEDROUTER_API_KEY。
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["SEEDROUTER_API_KEY"],
base_url="https://api.seedrouter.ai/v1",
max_retries=0,
)
response = client.responses.create(
model="gpt-6.2-sol",
input="Suggest one test for a CSV import with a missing header.",
reasoning={"effort": "low"},
max_output_tokens=256,
)
print(response.output_text)在傳輸內容中,傳送 POST /v1/responses。從類型為 message 的 output 項目中讀取文字,文字位於類型為 output_text 的內容部分。較早的項目可能包含推理內容或函式呼叫。Python SDK 回應中的 output_text 可為你彙整文字部分。使用部分結果前,請檢查 status 和 incomplete_details。
若要傳送圖片,請在使用者訊息中加入 input_image 內容部分,並省略頂層的 image 欄位。SeedRouter 支援同步與串流回應。請省略 background_options,並讓 background 保持未設定;2h 和 8h 背景時長目前無法使用。
使用託管子代理時,請傳送標頭 OpenAI-Beta: responses_multi_agent=v1,並設定 enabled 為 true 的 multi_agent 物件。選用的整數 max_concurrent_subagents 用來計算作用中的後代代理數量,不包含根代理;預設值為 3,最小值為 1。啟用委派時,請省略 reasoning.summary 和 max_tool_calls。子代理共用輸出預算。若要讀取最終答案,請選取 agent.agent_name 為 /root 且 phase 為 final_answer 的訊息項目。在進階 JSON 中輸入該物件時,Playground 會自動加入 beta 標頭。
curl https://api.seedrouter.ai/v1/responses \
-H "Authorization: Bearer $SEEDROUTER_API_KEY" \
-H "Content-Type: application/json" \
-H "OpenAI-Beta: responses_multi_agent=v1" \
-d '{
"model": "gpt-6.2-sol",
"input": "Ask one subagent to check whether 17 is prime. Give the result.",
"multi_agent": {"enabled": true, "max_concurrent_subagents": 1},
"max_output_tokens": 512
}'Chat Completions
curl https://api.seedrouter.ai/v1/chat/completions \
-H "Authorization: Bearer $SEEDROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.2-sol",
"messages": [{"role": "user", "content": "Suggest one test for a CSV import with a missing header."}],
"reasoning_effort": "low",
"max_completion_tokens": 256
}'Chat 回覆完成後會包含 choices[0].message.content。請查看 choices[0].finish_reason 以確認輸出限制。Chat 會回報 usage.prompt_tokens 和 usage.completion_tokens。Responses 會回報 usage.input_tokens 和 usage.output_tokens。
各端點的請求欄位
| 用途 | Responses | Chat Completions |
|---|---|---|
| 輸入 | input 字串或輸入項目 | messages 陣列 |
| 開發者指示 | 此請求的 instructions,或一則 developer 輸入訊息 | 一則 developer 訊息 |
| 使用者訊息中的圖片 | 類型為 input_image 的部分,包含字串 image_url | 類型為 image_url 的部分,URL 位於 image_url.url |
| 推理強度 | reasoning.effort | reasoning_effort |
| 輸出 token 預算 | max_output_tokens | max_completion_tokens |
| 輸出詳細程度 | text.verbosity | verbosity |
| 嚴格 JSON | text.format | response_format.json_schema |
| 函式呼叫 | tools, tool_choice, function_call_output | 使用 Responses 執行 GPT-6.2 工具呼叫 |
| 串流 | stream: true,具型別的事件 | stream: true,Chat completion 區塊 |
OpenAI 建議新整合先從 medium 推理開始。簡短回答請使用 low。若從 none 或 minimal 遷移,請選擇 low。請省略 temperature、top_p 和對數機率控制項,包括 Responses include 中的 message.output_text.logprobs。模型遷移指南
結構化輸出
Responses 的 JSON Schema 格式會將 name、strict 和 schema 與 type 並列。在 Chat 中,相同的三個欄位則放在 response_format.json_schema 內。
city_format = {
"name": "trip",
"strict": True,
"schema": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
"additionalProperties": False,
},
}
response = client.responses.create(
model="gpt-6.2-sol",
input="Return Paris in the city field.",
text={"format": {"type": "json_schema", **city_format}},
reasoning={"effort": "low"},
max_output_tokens=256,
)
print(response.output_text)若要在 Chat Completions 使用此結構描述,請傳入 response_format={"type": "json_schema", "json_schema": city_format}。剖析 JSON 前,請檢查回覆是否包含拒絕回應或達到 token 上限。
函式呼叫與串流
在 Responses 請求中,函式的 name 和 parameters 直接放在工具上。此範例沿用上方的結構描述。
response = client.responses.create(
model="gpt-6.2-sol",
input="Call record_city for Paris.",
tools=[{
"type": "function",
"name": "record_city",
"parameters": city_format["schema"],
"strict": True,
}],
tool_choice={"type": "function", "name": "record_city"},
reasoning={"effort": "low"},
max_output_tokens=256,
)
for item in response.output:
if item.type == "function_call":
print(item.call_id, item.name, item.arguments)在即時 SeedRouter 測試中,此請求回傳了一個名為 record_city 的 function_call,其引數可解碼為 {"city":"Paris"}。請驗證引數,並在你的應用程式中執行函式。在下一個 Responses 請求中,帶入原始輸入和回傳的輸出項目,再附加一個 function_call_output 項目,其中包含相符的 call_id 和字串 output。
若要即時接收文字,請設定 stream: true。在 Responses 中,串接 response.output_text.delta 事件中的 delta,並檢查是否出現 response.completed、response.incomplete 或 response.failed。在 Chat 中,收集 choices[].delta.content、檢查最終完成原因,並持續讀取直到 [DONE]。
存取權限與定價
使用 GET /v1/models 檢查你的金鑰是否有存取權限。若要查看可用群組,請使用相同的 Bearer 金鑰呼叫 GET /api/seedrouter/llm/groups?model=gpt-6.2-sol。若要選擇回傳的其中一個群組,請在選用的 X-SeedRouter-Group 標頭中傳送該群組 ID。省略此標頭時,會使用金鑰的預設選項。你也可以在遊樂場查看可用群組。
下載 OpenAPI · OpenAI 模型詳細資訊 · Responses 欄位 · Chat 欄位 · 錯誤代碼
