Session बनाएँ
/v1/agents/sessionsकिसी saved Agent version के लिए, या request में परिभाषित inline Agent के लिए Session बनाएँ। Agent configuration, Skill versions और MCP connections Session के पूरे जीवनकाल के लिए frozen रहते हैं। Sessions हमेशा SandBase के hosted cloud में चलते हैं, इसलिए कोई execution environment चुनना नहीं पड़ता। stream=true और initial input के साथ, response JSON Session के बजाय पहले turn का 201 Server-Sent Events stream होता है। Execution admission (balance और organization status) यहीं जाँचा जाता है। OpenAI SDK को environment argument चाहिए; OpenAI compatibility (/agents/openai-compatibility) देखें।
Headers
वैकल्पिक। न भेजने पर सर्विस खुद एक key बनाती है, इसलिए दोबारा भेजा गया request डुप्लिकेट बना सकता है। retry के लिए अपनी स्थिर key भेजें।
Request body
Strict JSON object।
Saved Agent ID (agt_ prefix)। Agent active होना चाहिए और उसका projection_status ready होना चाहिए। agent_id, agent, या दोनों भेजें।
Agent configuration। स्वीकार किए जाने वाले fields हैं model, instructions, runtime_profile (codex, claude, या mcode; default codex), service_tier, tools, text, reasoning और multi_agent, जिन्हें Create Agent की तरह validate किया जाता है। agent_id के बिना यह inline Agent परिभाषित करता है और model आवश्यक है; inline Agents में कोई Skills या MCP connections नहीं होते। agent_id के साथ, आपके भेजे गए हर field से saved version का वह field केवल इसी Session के लिए बदल जाता है। अज्ञात fields 400 लौटाते हैं।
Agent version। Default रूप से current version। inline Agent के साथ अनुमति नहीं है।
Session title।
वैकल्पिक पहला input: एक string, या ठीक एक message वाला array, जैसे [{"role":"user","content":[{"type":"input_text","text":"…"}]}]। अकेला object 400 लौटाता है।
Model override। agent.model OpenAI SDK वाला रूप है; दोनों भेजने पर उनका मेल खाना ज़रूरी है।
अधिकतम 16 string pairs।
true होने पर non-empty input आवश्यक है और text/event-stream body के साथ 201 लौटता है। Events, Stream events format (event: <type>, data: <json>) का उपयोग करते हैं; पहला event, agent.session.created, Session snapshot लाता है, जिसके बाद turn के item और output events आते हैं। Stream शुरू होने से पहले की validation, admission और अन्य errors सामान्य JSON error लौटाती हैं। Default false।
केवल OpenAI SDK compatibility के लिए। सीधे HTTP calls में इसे न भेजें; {"type":"openai_hosted"} स्वीकार किया जाता है और कोई अन्य type 400 लौटाता है।
Model credential। अपनी calling API key इस्तेमाल करने के लिए इसे न भेजें। {"type":"custom","base_url":"https://…","api_key":"…"} आपके अपने OpenAI-compatible endpoint को call करता है। Write-only।
इस Session के लिए /workspace में clone की जाने वाली GitHub repository: {"repository_id":"1195090324","ref":"main","connection_id":"plc_…"}। केवल repository_id आवश्यक है; ref default रूप से default branch है। न भेजने या null होने पर Agent की workspace repository (यदि हो) इस्तेमाल होती है, अन्यथा कुछ भी clone नहीं होता। Repository Agent के GitHub connection scope में होनी चाहिए। GitHub repository workspace (/agents/github-workspace) देखें।
Session object
create, get, update, rename, archive और unarchive द्वारा लौटाया जाता है।
ses_ prefix वाला Session ID।
Execution status: idle, in_progress या failed। requires_action अभी समर्थित नहीं है और 502 executor_contract_error के रूप में सामने आता है।
active या archived। Archived Sessions input अस्वीकार करते हैं।
code, message, action और वैकल्पिक retryable के साथ public failure।
Frozen Agent version और effective model।
effective Agent configuration का OpenAI-shaped snapshot, और token usage (जब तक कोई turn usage रिपोर्ट नहीं करता, तब तक null)।
Session का स्रोत। POST /v1/agents/sessions से बने Sessions direct और null source_id रिपोर्ट करते हैं।
rename, archive और unarchive के लिए compare-and-set token।