Skip to main content

OpenAI Provider

The OpenAI provider enables you to use OpenAI’s language models, including GPT-4, GPT-5, and o3 models, for text generation, structured outputs, tool calling, and more.

Installation

Setup

Get your API key from OpenAI’s platform and set it as an environment variable:

Usage

Basic Text Generation

Streaming Responses

Structured Output

Configuration

Custom Provider Instance

Provider Options

  • apiKey: Your OpenAI API key (defaults to OPENAI_API_KEY env var)
  • baseURL: Custom API endpoint URL
  • organization: OpenAI organization ID
  • project: OpenAI project ID
  • headers: Custom headers for requests

Available Models

Chat Models

  • gpt-5 - Latest GPT-5 model
  • gpt-4-turbo - GPT-4 Turbo
  • gpt-4 - GPT-4
  • gpt-3.5-turbo - GPT-3.5 Turbo

Reasoning Models

  • o3-mini - Smaller reasoning model
  • o3 - Advanced reasoning model

Embeddings

Available Models:
  • text-embedding-3-small (1536 dimensions)
  • text-embedding-3-large (3072 dimensions)
  • text-embedding-ada-002 (1536 dimensions)

Image Generation

Available Models:
  • dall-e-3 - Latest DALL-E model
  • dall-e-2 - Previous generation

Advanced Features

Tool Calling

Vision

Resources