## Create an agent

`client.beta.agents.create(AgentCreateParamsbody, RequestOptionsoptions?): Agent`

**post** `/agents`

Creates a reusable agent without storing credentials. See [agent configuration](/api/docs/guides/agents-api/configuration).

### Parameters

- `body: AgentCreateParams`

  - `model: string`

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

    `minLength: 0`, `maxLength: 1048576`

  - `compaction?: Compaction | null`

    Context compaction settings. Omission or null enables background compaction.

    - `async?: boolean | null`

      Whether to compact context in the background. Omission or null defaults to true. Set to false to use blocking compaction. Background compaction may increase token usage.

  - `experimental?: Experimental`

    Experimental agent settings. All experimental features default to disabled.

    - `time_awareness?: boolean`

      Whether to give the model periodic current-time reminders. Defaults to false.

  - `instructions?: string | null`

    Additional instructions appended to the agent's default base instructions. Omit or set to null to add no custom instructions.

    `minLength: 0`, `maxLength: 1048576`

  - `metadata?: Record<string, string> | 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.

  - `multi_agent?: MultiAgentConfigParam | null`

    Configuration for creating and coordinating subagents. Subagent tools are disabled by default.

    - `enabled: boolean`

      Whether subagent tools are enabled.

    - `max_concurrent_subagents?: number`

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

      `format: int64`, `minimum: 1`, `maximum: 4294967295`

  - `name?: string | null`

    A human-readable name for the agent. Omission or null leaves the agent unnamed.

    `minLength: 0`, `maxLength: 128`

  - `reasoning?: AgentReasoningParam | null`

    Configuration for model reasoning. Omission uses the model's default effort.

    - `effort?: "none" | "minimal" | "low" | 4 more | null`

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

      - `"none"`

      - `"minimal"`

      - `"low"`

      - `"medium"`

      - `"high"`

      - `"xhigh"`

      - `"max"`

    - `summary?: "concise" | "detailed" | "auto" | null`

      Controls whether the response includes a reasoning summary.

      - `"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" | "default" | "flex" | 3 more | null`

    The service tier used for model requests. Defaults to `auto`.

    - `"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.

    - `"ultrafast"`

      Uses the ultrafast service tier.

  - `text?: AgentTextParam | null`

    Configuration for generated text. Defaults to the `text` format and medium verbosity.

    - `format?: TextFormatParam | null`

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

      - `TextFormatParamText`

        Generates ordinary text without a structured-output constraint.

        - `type: "text"`

          The type of the object. Always `text`.

          - `"text"`

      - `TextFormatParamJSONSchema`

        Constrains generated text to a JSON Schema.

        - `schema: Record<string, unknown>`

          The JSON Schema that generated text must match.

        - `type: "json_schema"`

          The type of the object. Always `json_schema`.

          - `"json_schema"`

    - `verbosity?: "low" | "medium" | "high" | null`

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

      - `"low"`

        Produces less text.

      - `"medium"`

        Uses the default amount of text.

      - `"high"`

        Produces more text.

  - `tools?: Array<PersistedAgentToolParam> | null`

    Tools available to the agent. Defaults to an empty list. The tool list must fit within 3 MiB (3,145,728 bytes) of compact UTF-8 JSON.

    `minItems: 0`, `maxItems: 2000`

    - `PersistedAgentToolConfigParamFunction`

      A function defined by the application.

      - `description: string`

        A description of what the function does.

        `minLength: 0`, `maxLength: 1048576`

      - `name: string`

        The name of the function.

        `minLength: 0`, `maxLength: 1048576`

      - `parameters: Record<string, unknown>`

        A JSON Schema object describing the function's arguments.

      - `type: "function"`

        The type of the object. Always `function`.

        - `"function"`

      - `async?: boolean`

        Whether the agent continues without waiting for the function result. Defaults to `false`.

      - `defer_loading?: boolean`

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

    - `PersistedAgentToolConfigParamToolSearch`

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

      - `type: "tool_search"`

        The type of the object. Always `tool_search`.

        - `"tool_search"`

    - `PersistedAgentToolConfigParamProgrammaticToolCalling`

      Enables calling tools from model-generated code.

      - `type: "programmatic_tool_calling"`

        The type of the object. Always `programmatic_tool_calling`.

        - `"programmatic_tool_calling"`

      - `enabled?: boolean`

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

    - `PersistedAgentToolConfigParamMcp`

      Tools provided by a remote MCP server without stored credentials.

      - `server_label: string`

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

        `minLength: 0`, `maxLength: 1048576`

      - `transport: PersistedMcpTransportParam`

        The credential-free transport used to connect to the MCP server.

        - `PersistedMcpTransportConfigParamHTTP`

          Connects to an MCP server over HTTP.

          - `server_url: string`

            The URL of the MCP server.

            `minLength: 0`, `maxLength: 1048576`

          - `type: "http"`

            The type of the object. Always `http`.

            - `"http"`

          - `headers?: Record<string, string> | null`

            Non-secret HTTP headers sent to the MCP server.

        - `PersistedMcpTransportConfigParamStdio`

          Starts an MCP server as a local process.

          - `command: string`

            The command used to start the MCP server.

            `minLength: 0`, `maxLength: 1048576`

          - `cwd: string`

            The working directory used to start the MCP server.

            `minLength: 0`, `maxLength: 1048576`

          - `type: "stdio"`

            The type of the object. Always `stdio`.

            - `"stdio"`

          - `args?: Array<string> | null`

            Arguments passed to the MCP server command.

            `minItems: 0`, `maxItems: 16384`

          - `env_vars?: Array<string> | null`

            Environment variable names to inherit from the selected execution environment.

            `minItems: 0`, `maxItems: 16384`

      - `type: "mcp"`

        The type of the object. Always `mcp`.

        - `"mcp"`

      - `allowed_tools?: Array<string> | null`

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

        `minItems: 0`, `maxItems: 16384`

      - `connection_origin?: "service" | "environment" | null`

        Selects where outbound MCP HTTP connections originate.

        - `"service"`

          Uses the Managed Agents service network.

        - `"environment"`

          Uses the session's execution environment.

      - `credential_id?: string | null`

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

        `minLength: 0`, `maxLength: 1048576`

      - `request_metadata?: Record<string, unknown> | null`

        Metadata included with requests to this MCP server.

      - `required?: boolean`

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

    - `PersistedAgentToolConfigParamWebSearch`

      Web search.

      - `type: "web_search"`

        The type of the object. Always `web_search`.

        - `"web_search"`

      - `allowed_domains?: Array<string> | null`

        Domains the search may include.

        `minItems: 0`, `maxItems: 16384`

      - `context_size?: "low" | "medium" | "high" | null`

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

        - `"low"`

        - `"medium"`

        - `"high"`

      - `location?: Location | null`

        Approximate location used to localize search results.

        - `city?: string | null`

          The city name.

          `minLength: 0`, `maxLength: 1048576`

        - `country?: string | null`

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

          `minLength: 0`, `maxLength: 1048576`

        - `region?: string | null`

          The region or state name.

          `minLength: 0`, `maxLength: 1048576`

        - `timezone?: string | null`

          The IANA timezone, such as `America/Los_Angeles`.

          `minLength: 0`, `maxLength: 1048576`

      - `mode?: "disabled" | "cached" | "live" | null`

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

        - `"disabled"`

          Disables web search.

        - `"cached"`

          Uses cached search results.

        - `"live"`

          Searches the live web.

    - `PersistedAgentToolConfigParamComputerUse`

      Browser use in an OpenAI-hosted session.

      - `type: "computer_use"`

        The type of the object. Always `computer_use`.

        - `"computer_use"`

      - `include_screenshots?: boolean`

        Whether computer tool outputs include screenshots. Defaults to `false`.

    - `PersistedAgentToolConfigParamAutomations`

      Lets the agent manage its own scheduled wakeups.

      - `type: "automations"`

        The type of the object. Always `automations`.

        - `"automations"`

### Returns

- `Agent`

  A reusable agent scoped to the caller's project.

  - `id: string`

    The ID of the reusable agent.

    `minLength: 0`

  - `created_at: number`

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

    `format: int64`

  - `instructions: string | null`

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

    `minLength: 0`

  - `metadata: Record<string, string>`

    Custom string key-value pairs attached to the agent.

  - `model: string`

    The requested model name used for inference.

    `minLength: 0`

  - `multi_agent: MultiAgentConfig`

    The resolved configuration for creating and coordinating subagents.

    - `enabled: boolean`

      Whether subagent tools are enabled. Defaults to false.

    - `max_concurrent_subagents: number | null`

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

      `format: int64`, `minimum: 1`, `maximum: 4294967295`

  - `name: string | null`

    A human-readable name for the agent, or null if it is unnamed.

    `minLength: 0`

  - `object: "agent"`

    The object type. Always `agent`.

    - `"agent"`

  - `reasoning: AgentReasoning`

    The resolved reasoning configuration, including the model default for an omitted effort.

    - `effort: "none" | "minimal" | "low" | 4 more | null`

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

      - `"none"`

      - `"minimal"`

      - `"low"`

      - `"medium"`

      - `"high"`

      - `"xhigh"`

      - `"max"`

    - `summary: "concise" | "detailed" | "auto" | null`

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

      - `"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" | "default" | "flex" | 3 more`

    The resolved service-tier policy used for model requests.

    - `"auto"`

    - `"default"`

    - `"flex"`

    - `"priority"`

    - `"fast"`

    - `"ultrafast"`

  - `text: AgentText`

    The resolved configuration for text generated by the agent.

    - `format: TextFormat`

      The effective output format. Defaults to ordinary text.

      - `TextFormatResourceText`

        Generates ordinary text without a structured-output constraint.

        - `type: "text"`

          The type of the object. Always `text`.

          - `"text"`

      - `TextFormatResourceJSONSchema`

        Constrains generated text to a JSON Schema.

        - `schema: Record<string, unknown>`

          The JSON Schema that generated text must match.

        - `type: "json_schema"`

          The type of the object. Always `json_schema`.

          - `"json_schema"`

    - `verbosity: "low" | "medium" | "high"`

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

      - `"low"`

      - `"medium"`

      - `"high"`

  - `tools: Array<PersistedAgentTool>`

    Tools available to the agent.

    `minItems: 0`, `maxItems: 2000`

    - `PersistedAgentToolResourceFunction`

      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.

        `minLength: 0`

      - `name: string`

        The name of the function.

        `minLength: 0`

      - `parameters: Record<string, unknown>`

        A JSON Schema object describing the function's arguments.

      - `type: "function"`

        The type of the object. Always `function`.

        - `"function"`

      - `async?: boolean`

        Whether the agent continues without waiting for the function result.

    - `PersistedAgentToolResourceToolSearch`

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

      - `type: "tool_search"`

        The type of the object. Always `tool_search`.

        - `"tool_search"`

    - `PersistedAgentToolResourceProgrammaticToolCalling`

      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`.

        - `"programmatic_tool_calling"`

    - `PersistedAgentToolResourceMcp`

      Tools provided by a remote MCP server without stored credentials.

      - `allowed_tools: Array<string> | null`

        The MCP tools the agent may call, or null when all server tools are allowed.

        `minItems: 0`, `maxItems: 2000`

      - `connection_origin: "service" | "environment"`

        Where outbound MCP HTTP connections originate.

        - `"service"`

        - `"environment"`

      - `credential_id: string | null`

        The vault credential selected for this MCP server, if any.

        `minLength: 0`

      - `request_metadata: Record<string, 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.

        `minLength: 0`

      - `transport: PersistedMcpTransport`

        The credential-free transport used to connect to the MCP server.

        - `PersistedMcpTransportResourceHTTP`

          Connects to an MCP server over HTTP.

          - `headers: Record<string, string>`

            Non-secret HTTP headers sent to the MCP server.

          - `server_url: string`

            The URL of the MCP server.

            `minLength: 0`

          - `type: "http"`

            The type of the object. Always `http`.

            - `"http"`

        - `PersistedMcpTransportResourceStdio`

          Starts an MCP server as a local process.

          - `args: Array<string>`

            Arguments passed to the MCP server command.

            `minItems: 0`, `maxItems: 2000`

          - `command: string`

            The command used to start the MCP server.

            `minLength: 0`

          - `cwd: string`

            The working directory used to start the MCP server.

            `minLength: 0`

          - `env_vars: Array<string>`

            Environment variable names inherited from the execution environment.

            `minItems: 0`, `maxItems: 2000`

          - `type: "stdio"`

            The type of the object. Always `stdio`.

            - `"stdio"`

      - `type: "mcp"`

        The type of the object. Always `mcp`.

        - `"mcp"`

    - `PersistedAgentToolResourceWebSearch`

      Web search.

      - `allowed_domains: Array<string> | null`

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

        `minItems: 0`, `maxItems: 2000`

      - `context_size: "low" | "medium" | "high"`

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

        - `"low"`

        - `"medium"`

        - `"high"`

      - `location: Location | null`

        Approximate location used to localize search results, if provided.

        - `city: string | null`

          The city name.

          `minLength: 0`

        - `country: string | null`

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

          `minLength: 0`

        - `region: string | null`

          The region or state name.

          `minLength: 0`

        - `timezone: string | null`

          The IANA timezone, such as `America/Los_Angeles`.

          `minLength: 0`

      - `mode: "disabled" | "cached" | "live"`

        The source used for web search results.

        - `"disabled"`

        - `"cached"`

        - `"live"`

      - `type: "web_search"`

        The type of the object. Always `web_search`.

        - `"web_search"`

    - `PersistedAgentToolResourceComputerUse`

      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`.

        - `"computer_use"`

    - `PersistedAgentToolResourceAutomations`

      Lets the agent manage its own scheduled wakeups.

      - `type: "automations"`

        The type of the object. Always `automations`.

        - `"automations"`

  - `updated_at: number`

    The Unix timestamp, in seconds, when the agent was last updated.

    `format: int64`

  - `compaction?: Compaction`

    The effective context compaction settings.

    - `async: boolean`

      Whether context is compacted in the background. Defaults to true.

  - `experimental?: Experimental`

    The effective experimental settings for the agent.

    - `time_awareness: boolean`

      Whether the model receives periodic current-time reminders.

### Example

```typescript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

const agent = await client.beta.agents.create({ model: 'model' });

console.log(agent.id);
```

#### 201 — Example

```json
{
  "id": "id",
  "created_at": 0,
  "instructions": "instructions",
  "metadata": {
    "foo": "string"
  },
  "model": "model",
  "multi_agent": {
    "enabled": true,
    "max_concurrent_subagents": 1
  },
  "name": "name",
  "object": "agent",
  "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",
      "async": true
    }
  ],
  "updated_at": 0,
  "compaction": {
    "async": true
  },
  "experimental": {
    "time_awareness": true
  }
}
```
