Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation

Create an agent session

POST/agents/sessions

Creates a managed agent session, optionally submits initial input, and returns the session or streams its events when stream is true. See running sessions.

Body ParametersJSONExpand Collapse
environment: EnvironmentParam

An inline execution environment or a reference to an environment template.

One of the following:
None object { type }

Runs the agent without an execution environment.

type: "none"

The type of the object. Always none.

OpenAIHosted object { type, capability_directories, container_size, 10 more }

An existing OpenAI-hosted environment or new inline/template-based hosted configuration.

type: "openai_hosted"

The type of the object. Always openai_hosted.

capability_directories: optional array of string or null

Directories that contain capabilities exposed to the agent. Defaults to an empty list.

container_size: optional "small" or "medium" or "large"

The hosted container size. Omission selects the medium tier.

One of the following:
"small"
"medium"
"large"
desktop: optional object { enabled } or null

Desktop provisioning. Omission or null inherits the template setting, or defaults to disabled.

enabled: boolean

Whether to provision the desktop and its browser proxy.

env: optional map[string] or null

Environment variables made available to the agent.

environment_id: optional string

An existing prewarmed environment. Cannot be combined with a template or inline configuration.

minLength9
maxLength256
environment_template_id: optional string

A reusable hosted template applied before inline session configuration. Omitted fields inherit the template; network overrides cannot broaden its policy.

minLength0
maxLength64
files: optional array of HostedEnvironmentFileParam or null

Files available before the agent starts. Defaults to an empty list.

One of the following:
FileID object { file_id, path, type }

A file previously uploaded through the OpenAI Files API.

file_id: string

The ID of the uploaded file.

minLength1
maxLength256
path: string

The absolute destination path inside /workspace.

minLength1
maxLength4096
type: "file_id"

The type of the object. Always file_id.

Inline object { data, path, type }

A file supplied directly as standard-base64 data.

data: string

The standard-base64-encoded file contents.

minLength0
maxLength6990508
path: string

The absolute destination path inside /workspace.

minLength1
maxLength4096
type: "inline"

The type of the object. Always inline.

network: optional object { access, allowed_domains, blocked_domains } or null

Network access policy for the environment. If omitted, the API version determines whether network access is enabled or disabled.

access: "enabled" or "disabled" or "restricted"

The environment’s network access mode.

One of the following:
"enabled"

Allows unrestricted network access.

"disabled"

Disables network access.

"restricted"

Applies the configured domain restrictions.

allowed_domains: optional array of string or null

Domains the environment may access when network access is restricted.

blocked_domains: optional array of string or null

Domains blocked for both executor and browser when access is restricted. A nonempty list requires access: restricted and cannot be combined with nonempty allowed_domains. Wildcard domains are not supported.

packages: optional object { npm, python, system } or null

Packages to install in the environment. Defaults to empty package lists.

npm: optional array of string or null

npm packages to install globally. Defaults to an empty list.

python: optional array of string or null

Python packages to install. Defaults to an empty list.

system: optional array of string or null

System packages to install. Defaults to an empty list.

plugins: optional array of HostedPluginParam { description, name, source, type } or null

Plugins provided as inline ZIP archives. Defaults to an empty list.

description: string

The plugin description declared in .codex-plugin/plugin.json.

minLength0
maxLength1048576
name: string

The plugin name declared in .codex-plugin/plugin.json.

minLength1
maxLength64
source: InlineCapabilitySourceParam { data, media_type, type }

Provides ZIP bytes encoded with standard base64.

data: string

Standard-base64 encoded ZIP archive bytes.

minLength1
maxLength70254592
media_type: "application/zip"

The archive media type, always application/zip.

type: "base64"

The type of the object. Always base64.

type: "inline"

The type of the object. Always inline.

setup_commands: optional array of SetupCommandParam { command, cwd } or null

Ordered, confidential setup commands. Command bodies are never returned.

command: string

The shell command to execute.

minLength0
maxLength65536
cwd: optional string or null

The absolute working directory. Defaults to /workspace.

minLength0
maxLength4096
skills: optional array of HostedSkillParam or null

Skills referenced by ID or provided as inline ZIP archives. Defaults to an empty list.

One of the following:
SkillReference object { skill_id, type, version }

References a skill uploaded through the Skills API.

skill_id: string

The ID of the skill created through /v1/skills.

minLength1
maxLength64
type: "skill_reference"

The type of the object. Always skill_reference.

version: optional string or null

The skill version, a positive integer or latest; omission selects the default.

minLength0
maxLength1048576
Inline object { description, name, source, type }

Supplies a skill ZIP directly in the session request.

description: string

The skill description declared in SKILL.md.

minLength0
maxLength1048576
name: string

The skill name declared in SKILL.md.

minLength1
maxLength64
source: InlineCapabilitySourceParam { data, media_type, type }

Provides ZIP bytes encoded with standard base64.

data: string

Standard-base64 encoded ZIP archive bytes.

minLength1
maxLength70254592
media_type: "application/zip"

The archive media type, always application/zip.

type: "base64"

The type of the object. Always base64.

type: "inline"

The type of the object. Always inline.

SelfHosted object { type, workspace_directory, capability_directories }

An application-hosted environment configured inline.

type: "self_hosted"

The type of the object. Always self_hosted.

workspace_directory: string

Absolute project directory inside the self-hosted environment.

minLength0
maxLength1048576
capability_directories: optional array of string or null

Directories that contain capabilities exposed to the agent. Defaults to an empty list.

agent: optional object { instructions, model, multi_agent, 4 more }

Agent configuration. With agent_id, supplied fields override the saved agent for this session. Without agent_id, model is required.

instructions: optional string or null

Additional instructions appended to the agent’s default base instructions. Omit to leave unchanged.

minLength0
maxLength1048576
model: optional string

The model to use for the agent. The requested model name is preserved.

minLength0
maxLength1048576
multi_agent: optional MultiAgentConfigParam { enabled, max_concurrent_subagents } or null

Configuration for creating and coordinating subagents.

enabled: boolean

Whether subagent tools are enabled.

max_concurrent_subagents: optional number

Maximum number of subagents that may run concurrently. Defaults to 6.

formatint64
minimum1
maximum4294967295
reasoning: optional AgentReasoningParam { effort, summary } or null

Configuration for model reasoning. Omit to keep the current settings; pass null to reset to the model’s default effort.

effort: optional "none" or "minimal" or "low" or 4 more or null

The amount of reasoning effort the model should use. Omission lets the model select it.

One of the following:
"none"
"minimal"
"low"
"medium"
"high"
"xhigh"
"max"
summary: optional "concise" or "detailed" or "auto" or null

Controls whether the response includes a reasoning summary.

One of the following:
"concise"

Returns a concise reasoning summary when supported.

"detailed"

Returns a detailed reasoning summary when supported.

"auto"

Automatically selects the most detailed summary supported by the model.

service_tier: optional "auto" or "default" or "flex" or 2 more or null

The service tier used for model requests.

One of the following:
"auto"

Selects the service tier automatically.

"default"

Uses the default service tier.

"flex"

Uses the flex service tier.

"priority"

Uses the priority service tier.

"fast"

Uses the fast service tier.

text: optional AgentTextParam { format, verbosity } or null

Configuration for text generated by the agent.

format: optional TextFormatParam or null

The output format. Omission uses ordinary text ({"type": "text"}).

One of the following:
Text object { type }

Generates ordinary text without a structured-output constraint.

type: "text"

The type of the object. Always text.

JSONSchema object { schema, type }

Constrains generated text to a JSON Schema.

schema: map[unknown]

The JSON Schema that generated text must match.

type: "json_schema"

The type of the object. Always json_schema.

verbosity: optional "low" or "medium" or "high" or null

The amount of text the model should produce. Defaults to medium, matching Responses.

One of the following:
"low"

Produces less text.

"medium"

Uses the default amount of text.

"high"

Produces more text.

tools: optional array of AgentToolParam or null

Tools available to the agent. Omit to inherit, or pass null to clear them. The resolved tool list must fit within 3 MiB (3,145,728 bytes) of compact UTF-8 JSON.

One of the following:
Function object { description, name, parameters, 2 more }

A function defined by the application.

description: string

A description of what the function does.

minLength0
maxLength1048576
name: string

The name of the function.

minLength0
maxLength1048576
parameters: map[unknown]

A JSON Schema object describing the function’s arguments.

type: "function"

The type of the object. Always function.

defer_loading: optional boolean

Whether this function is deferred and discovered through tool search. Defaults to false.

ToolSearch object { type }

Discovers deferred function tools and loads them into the model context.

type: "tool_search"

The type of the object. Always tool_search.

ProgrammaticToolCalling object { type, enabled }

Enables calling tools from model-generated code.

type: "programmatic_tool_calling"

The type of the object. Always programmatic_tool_calling.

enabled: optional boolean

Whether tools can be called from model-generated code. Defaults to true.

Mcp object { server_label, transport, type, 5 more }

Tools provided by a remote MCP server.

server_label: string

A label used to identify the MCP server in tool calls.

minLength0
maxLength1048576

The transport used to connect to the MCP server.

One of the following:
HTTP object { server_url, type, authorization, headers }

Connects to an MCP server over HTTP.

server_url: string

The URL of the MCP server.

minLength0
maxLength1048576
type: "http"

The type of the object. Always http.

authorization: optional string or null

The authorization value sent to the MCP server, if any.

minLength0
maxLength1048576
headers: optional map[string] or null

Additional HTTP headers sent to the MCP server.

Stdio object { command, cwd, type, 3 more }

Starts an MCP server as a local process.

command: string

The command used to start the MCP server.

minLength0
maxLength1048576
cwd: string

The working directory used to start the MCP server.

minLength0
maxLength1048576
type: "stdio"

The type of the object. Always stdio.

args: optional array of string or null

Arguments passed to the MCP server command.

env: optional map[string] or null

Environment variables set for the MCP server process.

env_vars: optional array of string or null

Environment variable names to inherit from the selected execution environment.

type: "mcp"

The type of the object. Always mcp.

allowed_tools: optional array of string or null

The MCP tools the agent may call. All server tools are allowed when omitted.

connection_origin: optional "service" or "environment" or null

Selects where outbound MCP HTTP connections originate. Omitted or service uses the Managed Agents service network; environment uses the session’s selected environment.

One of the following:
"service"

Uses the Managed Agents service network.

"environment"

Uses the session’s execution environment.

credential_id: optional string or null

The attached vault credential used to authenticate this MCP server. Optional when exactly one attached credential matches the server URL.

minLength0
maxLength1048576
request_metadata: optional map[unknown] or null

Metadata included with requests to this MCP server.

required: optional boolean

Whether this MCP server must initialize before the first turn. Defaults to false.

WebSearch object { type, allowed_domains, context_size, 2 more }

Web search.

type: "web_search"

The type of the object. Always web_search.

allowed_domains: optional array of string or null

Domains the search may include.

context_size: optional "low" or "medium" or "high" or null

The amount of search context made available to the model. Defaults to medium.

One of the following:
"low"
"medium"
"high"
location: optional object { city, country, region, timezone } or null

Approximate location used to localize search results.

city: optional string or null

The city name.

minLength0
maxLength1048576
country: optional string or null

The two-letter ISO country code, such as US.

minLength0
maxLength1048576
region: optional string or null

The region or state name.

minLength0
maxLength1048576
timezone: optional string or null

The IANA timezone, such as America/Los_Angeles.

minLength0
maxLength1048576
mode: optional "disabled" or "cached" or "live" or null

The source used for web search results. Defaults to live.

One of the following:
"disabled"

Disables web search.

"cached"

Uses cached search results.

"live"

Searches the live web.

ComputerUse object { type, include_screenshots }

Browser use in an OpenAI-hosted session.

type: "computer_use"

The type of the object. Always computer_use.

include_screenshots: optional boolean

Whether computer tool outputs include screenshots. Defaults to false.

agent_id: optional string

The ID of a saved reusable agent. Omit agent to use its configuration unchanged.

minLength0
maxLength64
input: optional string or array of AgentSessionInputMessageParam { content, role, type } or null

Initial input to submit when the session is created. A string is shorthand for a single user message. Required when environment.type is none, or when stream is true for an environment that is not self_hosted; optional for self-hosted and non-streaming execution environments.

One of the following:
string
array of AgentSessionInputMessageParam { content, role, type }
content: array of InputContentParam

The content of the message.

One of the following:
InputText object { text, type }

Text input to the model.

text: string

The text sent to the model.

minLength0
maxLength1048576
type: "input_text"

The type of the object. Always input_text.

InputImage object { image_url, type }

Image input to the model.

image_url: string

The URL of the image sent to the model.

minLength0
maxLength1048576
type: "input_image"

The type of the object. Always input_image.

role: "user"

The role of the message author. Always user.

type: optional "message"

The type of the input item. Always message.

metadata: optional map[string] or null

Up to 16 string key-value pairs, with keys up to 64 and values up to 512 characters. Omission or null defaults to an empty map.

spend_control: optional object { limit } or null

Optional spending limit in USD cents. Omission or null creates an unlimited session.

limit: number or null

Positive USD cents, or null to remove the limit.

formatint64
minimum1
maximum4503599627370495
stream: optional boolean

Whether to stream session events as server-sent events. Defaults to false.

vault_ids: optional array of string or null

The IDs of vaults made available to the session.

ReturnsExpand Collapse
AgentSession object { id, agent, created_at, 10 more }

A Managed Agents session.

id: string

The ID of the session.

minLength0
agent: object { id, instructions, model, 6 more }

The agent running in the session.

id: string

The ID of the agent.

minLength0
instructions: string or null

Custom instructions appended to the agent’s default base instructions.

minLength0
model: string

The model used by the agent.

minLength0
multi_agent: MultiAgentConfig { enabled, max_concurrent_subagents }

Configuration for creating and coordinating subagents.

enabled: boolean

Whether subagent tools are enabled. Defaults to false.

max_concurrent_subagents: number or null

Maximum number of subagents that may run concurrently, or null when disabled. Defaults to 6 when enabled.

formatint64
minimum1
maximum4294967295
name: string or null

The reusable agent’s name when the session was created, or null if no name was saved. Later changes to the agent’s name do not affect this value.

minLength0
reasoning: AgentReasoning { effort, summary }

The agent’s reasoning configuration.

effort: "none" or "minimal" or "low" or 4 more or null

The requested reasoning effort, or null when the model selects its own default.

One of the following:
"none"
"minimal"
"low"
"medium"
"high"
"xhigh"
"max"
summary: "concise" or "detailed" or "auto" or null

The requested reasoning summary format, or null when summaries are disabled.

One of the following:
"concise"

Returns a concise reasoning summary when supported.

"detailed"

Returns a detailed reasoning summary when supported.

"auto"

Automatically selects the most detailed summary supported by the model.

service_tier: "auto" or "default" or "flex" or 3 more

The effective service-tier policy for model requests. Defaults to auto.

One of the following:
"auto"
"default"
"flex"
"priority"
"fast"
"ultrafast"
text: AgentText { format, verbosity }

Configuration for text generated by the agent.

format: TextFormat

The effective output format. Defaults to ordinary text.

One of the following:
Text object { type }

Generates ordinary text without a structured-output constraint.

type: "text"

The type of the object. Always text.

JSONSchema object { schema, type }

Constrains generated text to a JSON Schema.

schema: map[unknown]

The JSON Schema that generated text must match.

type: "json_schema"

The type of the object. Always json_schema.

verbosity: "low" or "medium" or "high"

The amount of text produced by the agent. Defaults to medium.

One of the following:
"low"
"medium"
"high"
tools: array of AgentTool

Tools available to the agent.

One of the following:
Function object { defer_loading, description, name, 2 more }

A function defined by the application.

defer_loading: boolean

Whether the function is deferred and discovered through tool search.

description: string

A description of what the function does.

minLength0
name: string

The name of the function.

minLength0
parameters: map[unknown]

A JSON Schema object describing the function’s arguments.

type: "function"

The type of the object. Always function.

ProgrammaticToolCalling object { enabled, type }

Enables calling tools from model-generated code.

enabled: boolean

Whether tools can be called from model-generated code.

type: "programmatic_tool_calling"

The type of the object. Always programmatic_tool_calling.

Mcp object { allowed_tools, connection_origin, credential_id, 5 more }

Tools provided by a remote MCP server.

allowed_tools: array of string or null

The MCP tools the agent may call.

connection_origin: "service" or "environment"

Where outbound MCP HTTP connections originate.

One of the following:
"service"
"environment"
credential_id: string or null

The attached vault credential selected for this MCP server, if any. Optional when exactly one attached credential matches the server URL.

minLength0
request_metadata: map[unknown]

Metadata included with requests to this MCP server.

required: boolean

Whether this MCP server must initialize before the first turn.

server_label: string

A label used to identify the MCP server in tool calls.

minLength0
transport: McpTransport

The transport used to connect to the MCP server.

One of the following:
HTTP object { server_url, type }

Connects to an MCP server over HTTP.

server_url: string

The URL of the MCP server.

minLength0
type: "http"

The type of the object. Always http.

Stdio object { args, command, cwd, 2 more }

Starts an MCP server as a local process.

args: array of string

Arguments passed to the MCP server command.

command: string

The command used to start the MCP server.

minLength0
cwd: string

The working directory used to start the MCP server.

minLength0
env_vars: array of string

Environment variable names inherited from the execution environment.

type: "stdio"

The type of the object. Always stdio.

type: "mcp"

The type of the object. Always mcp.

WebSearch object { allowed_domains, context_size, location, 2 more }

Web search.

allowed_domains: array of string or null

Allowed search domains, or null when the search is unrestricted.

context_size: "low" or "medium" or "high"

The amount of search context made available to the model. Defaults to medium.

One of the following:
"low"
"medium"
"high"
location: object { city, country, region, timezone } or null

Approximate location used to localize search results, if provided.

city: string or null

The city name.

minLength0
country: string or null

The two-letter ISO country code, such as US.

minLength0
region: string or null

The region or state name.

minLength0
timezone: string or null

The IANA timezone, such as America/Los_Angeles.

minLength0
mode: "disabled" or "cached" or "live"

The source used for web search results.

One of the following:
"disabled"
"cached"
"live"
type: "web_search"

The type of the object. Always web_search.

ComputerUse object { include_screenshots, type }

Browser use in an OpenAI-hosted session.

include_screenshots: boolean

Whether computer tool outputs include screenshots.

type: "computer_use"

The type of the object. Always computer_use.

created_at: number

The Unix timestamp, in seconds, when the session was created.

formatint64
environment: Environment

The execution environment for the session.

One of the following:
None object { type }

The session talks to CCA without selecting or provisioning an execution environment.

type: "none"

The type of the object. Always none.

OpenAIHosted object { id, capability_directories, desktop, 7 more }

An environment hosted by OpenAI.

id: string

The public ID of the environment.

minLength0
capability_directories: array of string

Directories that contain capabilities exposed to the agent.

desktop: object { enabled }

The effective desktop configuration.

enabled: boolean

Whether the environment provisions a desktop and browser proxy.

files: array of HostedEnvironmentFile

Files available in the environment, excluding their contents.

One of the following:
HostedEnvironmentFileID object { id, file_id, path, 2 more }

A file copied from the OpenAI Files API.

id: string

The session-scoped ID of the file in the execution environment.

minLength0
file_id: string

The ID of the uploaded file.

minLength0
path: string

The file’s absolute path inside the environment.

minLength0
size_bytes: number

The decoded file size in bytes.

formatint64
minimum0
type: "file_id"

The type of the object. Always file_id.

Inline object { id, path, size_bytes, type }

A file supplied inline when the session was created.

id: string

The session-scoped ID of the file in the execution environment.

minLength0
path: string

The file’s absolute path inside the environment.

minLength0
size_bytes: number

The decoded file size in bytes.

formatint64
minimum0
type: "inline"

The type of the object. Always inline.

network: object { access, allowed_domains }

The effective network access policy for the environment.

access: "enabled" or "disabled" or "restricted"

The environment’s network access mode.

One of the following:
"enabled"

Allows unrestricted network access.

"disabled"

Disables network access.

"restricted"

Applies the configured domain restrictions.

allowed_domains: array of string

Domains the environment may access when network access is restricted.

packages: object { npm, python, system }

Packages installed in the environment.

npm: array of string

npm packages installed globally in the environment.

python: array of string

Python packages installed in the environment.

system: array of string

System packages installed in the environment.

plugins: array of HostedPlugin { description, name, type }

Plugins installed in the environment, excluding their archive contents.

description: string

The installed plugin description.

minLength0
name: string

The installed plugin name.

minLength0
type: "inline"

The type of the object. Always inline.

skills: array of HostedSkill

Skills installed in the environment, excluding their archive contents.

One of the following:
HostedSkillReference object { description, name, skill_id, 2 more }

A skill installed from the Skills API.

description: string

The installed skill description.

minLength0
name: string

The installed skill name.

minLength0
skill_id: string

The referenced skill ID.

minLength0
type: "skill_reference"

The type of the object. Always skill_reference.

version: string

The concrete skill version installed for this session.

minLength0
Inline object { description, name, type }

A skill installed from an inline ZIP archive.

description: string

The installed skill description.

minLength0
name: string

The installed skill name.

minLength0
type: "inline"

The type of the object. Always inline.

type: "openai_hosted"

The type of the object. Always openai_hosted.

container_size: optional "small" or "medium" or "large" or null

The effective CPU and memory tier, or null when unknown or outside the public tiers.

One of the following:
"small"
"medium"
"large"
SelfHosted object { id, capability_directories, remote_url, 2 more }

An environment hosted by the application.

id: string

The public ID of the environment.

minLength0
capability_directories: array of string

Directories that contain capabilities exposed to the agent.

remote_url: string

Pass this URL unchanged to codex exec-server --remote when connecting this environment.

minLength0
type: "self_hosted"

The type of the object. Always self_hosted.

workspace_directory: string

The absolute project directory inside the environment. Defaults to /workspace.

minLength0
error: string or null

The error that caused the session to fail, if any.

minLength0
last_active_at: number

The Unix timestamp, in seconds, when the session was last active.

formatint64
metadata: map[string]

Custom string key-value pairs attached to the session.

object: "agent.session"

The object type. Always agent.session.

required_actions: array of ComputerUseApprovalRequest { request, request_id, turn_id, type } or FunctionCall { arguments, call_id, name, 2 more } or EnvironmentConnection { environment_id, type }

Actions that must be completed before the session can continue.

One of the following:
ComputerUseApprovalRequest object { request, request_id, turn_id, type }

Respond to a computer-use request.

request: BrowserAuthentication { credential_origin, fields, options, 2 more } or BrowserOriginAccess { origin, reason, type }

The information needed to render the request.

One of the following:
BrowserAuthentication object { credential_origin, fields, options, 2 more }

A registered form awaiting the application’s response.

credential_origin: string or null

The registered form or frame origin where values will be entered.

minLength0
fields: array of object { id, label, required, type }

Controls to render. All submitted values are sensitive.

id: string

The field ID to submit as field_id in a fields entry.

minLength0
label: string

The label to display beside the control.

minLength0
required: boolean

Whether this control requires a nonempty value.

type: string

The rendering type, such as email, password, or text.

minLength0
options: array of object { id, field_ids, label }

Sign-in methods. Empty for a plain form.

id: string

The option ID to submit as selected_option.

minLength0
field_ids: array of string

IDs from the registered fields that this method accepts.

label: string

The method label to display.

minLength0
reason: string or null

Why the agent needs the user to sign in.

minLength0
type: "browser_authentication"

The type of the object. Always browser_authentication.

BrowserOriginAccess object { origin, reason, type }

A browser origin awaiting the application’s approval decision.

origin: string

The origin the browser needs permission to access.

minLength0
reason: string or null

The browser’s explanation for this request, or null when unavailable.

minLength0
type: "browser_origin_access"

The type of the object. Always browser_origin_access.

request_id: string

The registered request ID to echo when responding.

minLength0
turn_id: string

The turn that requested approval.

minLength0
type: "computer_use_approval_request"

The type of the object. Always computer_use_approval_request.

FunctionCall object { arguments, call_id, name, 2 more }

Run a function tool and submit its result.

arguments: unknown

The arguments supplied by the model.

call_id: string

The ID to include when submitting the function result.

minLength0
name: string

The function name.

minLength0
turn_id: string

The ID of the turn that requested the function call.

minLength0
type: "function_call"

The type of the object. Always function_call.

EnvironmentConnection object { environment_id, type }

Reconnect a session environment.

environment_id: string

The ID of the environment to reconnect.

minLength0
type: "environment_connection"

The type of the object. Always environment_connection.

status: "idle" or "in_progress" or "requires_action" or "failed"

The current status of the session.

One of the following:
"idle"

The session has no turn in progress and is ready for input. A hosted environment may still be provisioning.

"in_progress"

The session is processing a turn.

"requires_action"

The session is waiting for one or more required actions.

"failed"

The session failed.

usage: TokenUsage { input_tokens, input_tokens_details, output_tokens, 2 more } or null

Best-effort token usage for the session, or null if unknown. Recorded usage may change.

input_tokens: number

The number of input tokens used by the agent.

formatint64
input_tokens_details: object { cached_tokens }

A breakdown of the agent’s input token usage.

cached_tokens: number

The number of input tokens retrieved from the prompt cache.

formatint64
output_tokens: number

The number of output tokens generated by the agent.

formatint64
output_tokens_details: object { reasoning_tokens }

A breakdown of the agent’s output token usage.

reasoning_tokens: number

The number of output tokens used for reasoning.

formatint64
total_tokens: number

The total number of input and output tokens used by the agent.

formatint64
vault_ids: array of string

The IDs of vaults made available to the session.

spend_control: optional object { consumed, limit }

Configured spending limit and best-effort consumption, in USD cents. Unlimited sessions omit this object.

consumed: number or null

Best-effort recorded spend floored to whole USD cents, or null when unavailable.

minimum0
limit: number

The configured positive limit in USD cents.

formatint64
minimum1
maximum4503599627370495

Create an agent session

curl https://api.openai.com/v1/agents/sessions \
    -H 'Content-Type: application/json' \
    -H 'OpenAI-Beta: agents=v1' \
    -H "Authorization: Bearer $OPENAI_API_KEY" \
    -d '{
          "environment": {
            "type": "none"
          }
        }'
{
  "id": "id",
  "agent": {
    "id": "id",
    "instructions": "instructions",
    "model": "model",
    "multi_agent": {
      "enabled": true,
      "max_concurrent_subagents": 1
    },
    "name": "name",
    "reasoning": {
      "effort": "none",
      "summary": "concise"
    },
    "service_tier": "auto",
    "text": {
      "format": {
        "type": "text"
      },
      "verbosity": "low"
    },
    "tools": [
      {
        "defer_loading": true,
        "description": "description",
        "name": "name",
        "parameters": {
          "foo": "bar"
        },
        "type": "function"
      }
    ]
  },
  "created_at": 0,
  "environment": {
    "type": "none"
  },
  "error": "error",
  "last_active_at": 0,
  "metadata": {
    "foo": "string"
  },
  "object": "agent.session",
  "required_actions": [
    {
      "request": {
        "credential_origin": "credential_origin",
        "fields": [
          {
            "id": "id",
            "label": "label",
            "required": true,
            "type": "type"
          }
        ],
        "options": [
          {
            "id": "id",
            "field_ids": [
              "string"
            ],
            "label": "label"
          }
        ],
        "reason": "reason",
        "type": "browser_authentication"
      },
      "request_id": "request_id",
      "turn_id": "turn_id",
      "type": "computer_use_approval_request"
    }
  ],
  "status": "idle",
  "usage": {
    "input_tokens": 0,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 0,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 0
  },
  "vault_ids": [
    "string"
  ],
  "spend_control": {
    "consumed": 0,
    "limit": 1
  }
}
Returns Examples
{
  "id": "id",
  "agent": {
    "id": "id",
    "instructions": "instructions",
    "model": "model",
    "multi_agent": {
      "enabled": true,
      "max_concurrent_subagents": 1
    },
    "name": "name",
    "reasoning": {
      "effort": "none",
      "summary": "concise"
    },
    "service_tier": "auto",
    "text": {
      "format": {
        "type": "text"
      },
      "verbosity": "low"
    },
    "tools": [
      {
        "defer_loading": true,
        "description": "description",
        "name": "name",
        "parameters": {
          "foo": "bar"
        },
        "type": "function"
      }
    ]
  },
  "created_at": 0,
  "environment": {
    "type": "none"
  },
  "error": "error",
  "last_active_at": 0,
  "metadata": {
    "foo": "string"
  },
  "object": "agent.session",
  "required_actions": [
    {
      "request": {
        "credential_origin": "credential_origin",
        "fields": [
          {
            "id": "id",
            "label": "label",
            "required": true,
            "type": "type"
          }
        ],
        "options": [
          {
            "id": "id",
            "field_ids": [
              "string"
            ],
            "label": "label"
          }
        ],
        "reason": "reason",
        "type": "browser_authentication"
      },
      "request_id": "request_id",
      "turn_id": "turn_id",
      "type": "computer_use_approval_request"
    }
  ],
  "status": "idle",
  "usage": {
    "input_tokens": 0,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 0,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 0
  },
  "vault_ids": [
    "string"
  ],
  "spend_control": {
    "consumed": 0,
    "limit": 1
  }
}