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

client.Beta.Agents.New(ctx, body) (*Agent, error)
POST/agents

Creates a reusable agent without storing credentials. See agent configuration.

ParametersExpand Collapse
body BetaAgentNewParams
Model param.Field[string]

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

minLength0
maxLength1048576
Instructions param.Field[string]Optional

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

minLength0
maxLength1048576
Metadata param.Field[map[string, string]]Optional

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.

MultiAgent param.Field[MultiAgentConfigParamResp]Optional

Explicit configuration for creating and coordinating subagents.

Name param.Field[string]Optional

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

minLength0
maxLength128
Reasoning param.Field[AgentReasoningParamResp]Optional

Reasoning configuration for the agent.

ServiceTier param.Field[BetaAgentNewParamsServiceTier]Optional

The service tier used for model requests.

Text param.Field[AgentTextParamResp]Optional

Configuration for text generated by the agent.

Tools param.Field[[]PersistedAgentToolParamUnionResp]Optional

Tools available to the agent. Defaults to an empty list.

ReturnsExpand Collapse
type Agent struct{…}

A reusable agent scoped to the caller’s project.

ID string

The ID of the reusable agent.

minLength0
CreatedAt int64

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

formatint64
Instructions string

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

minLength0
Metadata map[string, string]

Custom string key-value pairs attached to the agent.

Model string

The requested model name used for inference.

minLength0
MultiAgent MultiAgentConfig

The resolved configuration for creating and coordinating subagents.

Name string

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

minLength0
Object Agent

The object type. Always agent.

Reasoning AgentReasoning

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

ServiceTier AgentServiceTier

The resolved service-tier policy used for model requests.

The resolved configuration for text generated by the agent.

Tools available to the agent.

UpdatedAt int64

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

formatint64

Create an agent

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAPIKey("My API Key"),
  )
  agent, err := client.Beta.Agents.New(context.TODO(), openai.BetaAgentNewParams{
    Model: "model",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", agent.ID)
}
{
  "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"
    }
  ],
  "updated_at": 0
}
Returns Examples
{
  "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"
    }
  ],
  "updated_at": 0
}