agents/api
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