apicheats.dev openai/llms.txt Raw .md
POST

POST /agents/sessions — OpenAI API

OpenAI API key (required); https://api.openai.com/v1

OpenAI API

Create an agent session

Base URL
https://api.openai.com/v1
Auth
Authorization: Bearer <OPENAI_API_KEY>
Last verified
2026-10-20 · upstream hash matched
Actions Try in browser→
Agents: curl -H "Accept: text/markdown" this URL
→ 364 tokens · Vary: Accept

Critical gotchas

The Responses API is the primary interface for new text and tool workflows; Chat Completions remains a separate compatibility API.

Audio transcription uploads use multipart form data rather than a JSON request body.

cURL

curl -X POST 'https://api.openai.com/v1/agents/sessions' \  -H "Authorization: Bearer $OPENAI_API_KEY" \  -H 'Content-Type: application/json' \  -d '{  "environment": {    "type": "none"  }}'

Parameters

Name In Type Required Description
metadata body object No 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.
agent body object No Agent configuration for a session. Omitted fields inherit from `agent_id` when supplied. Supplied objects and arrays replace the whole field; null resets nullable fields.
agent_id body string No The ID of a saved reusable agent. Omit `agent` to use its configuration unchanged.
environment body object Yes The execution environment and optional reusable template for a session.
vault_ids body string[] No The IDs of vaults made available to the session.
input body string No 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.
stream body boolean No Whether to stream session events as server-sent events. Defaults to `false`.

Response 200 OK

{
  "metadata": {},
  "id": "string",
  "object": "agent.session",
  "created_at": 0,
  "last_active_at": 0,
  "status": "idle",
  "required_actions": [
    {
      "type": "computer_use_approval_request",
      "turn_id": "string",
      "request_id": "string",
      "request": {
        "type": "browser_authentication",
        "reason": "string",
        "credential_origin": "string",
        "fields": [
          {
            "id": "[recursive or deeply nested schema]",
            "label": "[recursive or deeply nested schema]",
            "type": "[recursive or deeply nested schema]",
            "required": "[recursive or deeply nested schema]"
          }
        ],
        "options": [
          {
            "id": "[recursive or deeply nested schema]",
            "label": "[recursive or deeply nested schema]",
            "field_ids": "[recursive or deeply nested schema]"
          }
        ]
      }
    }
  ],
  "error": "string",
  "agent": {
    "id": "string",
    "name": "string",
    "model": "string",
    "reasoning": {
      "effort": "none",
      "summary": "concise"
    },
    "text": {
      "format": {
        "type": "text"
      },
      "verbosity": "low"
    },
    "service_tier": "auto",
    "instructions": "string",
    "tools": [
      {
        "type": "function",
        "name": "string",
        "description": "string",
        "parameters": {},
        "defer_loading": true
      }
    ],
    "multi_agent": {
      "enabled": true,
      "max_concurrent_subagents": 0
    }
  },
  "environment": {
    "type": "none"
  },
  "vault_ids": [
    "string"
  ],
  "usage": {
    "input_tokens": 0,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 0,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 0
  }
}
Get a free OpenAI API key → sponsored

Affiliate link - we may earn a commission, at no extra cost to you.