Skip to main content

Overview

The OpenAI provider connects to GPT models including GPT-4, GPT-4o, o1, and GPT-3.5. It also serves as the base for OpenAI-compatible providers. Source: crates/goose/src/providers/openai.rs

Configuration

Environment Variables

string
Your OpenAI API key from https://platform.openai.com/api-keys (optional for some compatible providers)
string
default:"https://api.openai.com"
API endpoint URL
string
default:"v1/chat/completions"
API path for chat completions
string
OpenAI organization ID (optional)
string
OpenAI project ID (optional)
number
default:"600"
Request timeout in seconds
string
Custom headers in format: Header1=Value1,Header2=Value2 (stored securely)

Setup

Supported Models

GPT-4 Series

  • gpt-4o (default) - GPT-4 Optimized (128K context)
  • gpt-4o-mini (fast model) - Smaller, faster GPT-4o (128K context)
  • gpt-4.1 - Latest GPT-4 (128K context)
  • gpt-4.1-mini - Smaller GPT-4.1 (128K context)
  • gpt-4-turbo - GPT-4 Turbo (128K context)

Reasoning Models

  • o1 - Advanced reasoning model (200K context)
  • o3 - Next-generation reasoning (200K context)
  • o4-mini - Compact reasoning model (128K context)

GPT-5 Series (Future)

  • gpt-5-nano - Ultra-efficient model (400K context)
  • gpt-5.1-codex - Code-specialized model (400K context)
  • gpt-5-codex - Code generation model (400K context)

Legacy

  • gpt-3.5-turbo - GPT-3.5 Turbo (16K context)
Documentation: https://platform.openai.com/docs/models

Usage

Basic Usage

Custom Configuration

Using Fast Models

Advanced Features

Embeddings

The OpenAI provider supports text embeddings:
Default embedding model: text-embedding-3-small (configure via GOOSE_EMBEDDING_MODEL)

Organization & Project Headers

For team accounts:
These are sent as headers:

Custom Headers

For proxies or special configurations:

Responses API (GPT-5 Codex)

The provider automatically uses the Responses API for codex models:
You can force the responses API with a custom base path:

OpenAI-Compatible Providers

Many providers offer OpenAI-compatible APIs. Configure by changing the host:

Example: Local LLM Server

Example: Azure OpenAI

Use the dedicated Azure provider, or configure manually:

Implementation Details

Provider Metadata

API Format

Chat Completions API:

Authentication

Uses Bearer token authentication:
Or no authentication for compatible providers:

Streaming

Supports Server-Sent Events (SSE) streaming:

Path Mapping

The provider intelligently maps base paths:

Error Handling

Fetching Models

Usage Tracking

Custom Provider Configuration

For advanced use cases, create a provider programmatically:

See Also