agents/apiTHE ENCYCLOPEDIA
Core concepts

Agent configuration & reusable definitions

Separate reusable behavior from session history, environment settings, and application authorization.

Choose model
Write instructions
Allow tools
Create session
Evaluate results

Configuration is not memory

An agent definition describes model, instructions, tools, and supported reasoning or output controls. Supply it inline for a session or save reusable settings. A session owns the conversation and work. Reusing an agent definition must not be treated as sharing one user's history with another user.

Create a narrowly scoped agent

Install the current openai package and set OPENAI_API_KEY on your server. The example uses no compute environment because it needs neither a filesystem nor shell commands. It performs a billable API request. Your project must have access to the model and Agents API.

Example
import OpenAI from "openai";
const client = new OpenAI();
const session = await client.beta.agents.sessions.create({
  agent: {
    model: "gpt-6-astra",
    instructions: "Explain technical concepts with concrete examples.",
  },
  environment: { type: "none" },
  input: "Explain how a session differs from an agent definition.",
});
console.log(session.id);

Connect capabilities deliberately

Add only the tools the task needs. Instructions express intended behavior; tool handlers still enforce ownership and permissions. Choose sandbox settings separately from model behavior. A saved configuration is not permission to read every customer's data.

Compare changes before rollout

Application-side practice: record the configuration version alongside each job and evaluate representative tasks before changing the default. Compare answer correctness, tool choices, latency, and cost. Keep the previous configuration available for new jobs if the candidate regresses; do not assume updating settings rewrites existing session history.

Read the official reference

Check the source for current API fields, account requirements, and service limits.

OpenAI: configuration

38 matching topics

What is the OpenAI Agents API?FoundationsAgents API vs Agents SDK vs Responses APIComparisonsAgents API quickstartGetting startedSessions, turns & durable stateCore conceptsHosted vs self-hosted sandboxesInfrastructureConnect MCP servers to Agents APITools & integrationsFunction calling & application toolsTools & integrationsMulti-agent orchestrationCore conceptsStreaming, webhooks & event handlingIntegration guidesFiles, outputs & published artifactsCore conceptsVaults & MCP authenticationTools & integrationsAgent security & credential boundariesProductionTracing, usage & debuggingProductionAgents API pricing & cost planningProductionOpenAI Agents API with PythonGetting startedAgents API with TypeScript & Next.jsIntegration guidesWhat is the OpenAI Agents SDK?FoundationsResponses API in the agent stackFoundationsAgent Skills & SKILL.mdTools & integrationsProgrammatic Tool CallingTools & integrationsRAG, file search & vector storesTools & integrationsWeb search & source citationsTools & integrationsChatKit & Agent BuilderIntegration guidesAgent configuration & reusable definitionsCore conceptsPlugins: connect skills and MCP toolsTools & integrationsSandbox lifecycle & executor connectionsInfrastructureWebhook verification, queues & deduplicationIntegration guidesAgent retries, timeouts & failure recoveryProductionAgent evaluations & regression testingProductionWhich parts of the agent stack do you need?FoundationsAgents API contract quick referenceIntegration guidesOrder agent reference: approval, recovery & evaluationIntegration guidesBuild a Next.js order agent: server, tools & streamingIntegration guidesPython Agents API example with a real tool loopGetting startedHuman approval & prompt injection defensesProductionAgents API troubleshooting: symptoms, checks & recoveryProductionAgent tool support & runtime ownership matrixComparisonsAgent resources, relationships & task stateCore concepts
K to open Esc to close