Skip to main content
Enabled when OPENAI_API_KEY is set in your environment.

Overview

The @standardagents/openai package provides the OpenAI provider factory for Standard Agents. It enables direct access to OpenAI models with typed providerOptions and built-in provider tools.

Key Features

  • Direct OpenAI API access with automatic client management
  • Typed providerOptions with TypeScript autocompletion
  • Built-in provider tools (web search, file search, code interpreter, image generation)
  • Model capability detection and icon support

Installation

npm
pnpm
yarn

Quick Start

agents/models/gpt_5_4.ts

Provider Factory

The openai export is a provider factory function that creates OpenAI provider instances:
Unlike the legacy string-based provider: 'openai', the new API uses an imported factory function. This enables typed providerOptions and runtime validation.

Connection Config Slots

The OpenAI factory exposes connection-level config slots that defineProvider sub-providers can override: Use this for OpenAI-compatible providers that share request/response behavior but use a different endpoint and credential:
agents/providers/darkbloom.ts

Provider Options

The openai factory includes a typed schema for provider-specific options:

Available Options

Type Safety

The providerOptions type is automatically inferred from the provider:

Provider Tools

OpenAI provides built-in tools that execute on OpenAI’s servers and can be used alongside your custom tools:
All current GPT-5.4 models (gpt-5.4, gpt-5.4-mini, gpt-5.4-nano) support these built-in tools. See OpenAI’s tool documentation for the current per-model compatibility matrix.

Using Provider Tools

Enable provider tools in your model definition:
Then reference them in prompts:

Tool Requirements

Some provider tools require thread environment variables (tenvs): file_search:
Provider tools are executed by OpenAI’s servers, not locally. Results come back in the API response and are recorded through Standard Agents’ generic provider-tool log path.

Model Capabilities

Set capabilities to help the framework understand what the model supports:

Environment Setup

Set your OpenAI API key as an environment variable:
.dev.vars
For Cloudflare Workers:

Example Configurations

High-Performance Model

Budget Model

Reasoning Model

Exports

Next Steps

Models

Learn about model configuration

OpenRouter

Access multiple providers via OpenRouter

Tools

Create custom tools

defineModel API

Complete API reference