Skip to main content
The OpenAI provider supports GPT models, reasoning models (o1/o3/o4), and Azure OpenAI deployments.

Configuration

string
required
Your OpenAI API key from OpenAI PlatformNot required if using Azure Identity authentication
string
Custom base URL for API requests
  • OpenAI: https://api.openai.com/v1 (default)
  • Azure: https://<resource>.openai.azure.com
string
required
Model identifier. Examples:
  • gpt-4.5-turbo
  • gpt-4o
  • o1-preview
  • o3-mini
  • deepseek-reasoner
OpenAiCompatibleModelInfo
Model metadata including:
  • maxTokens - Maximum output tokens
  • temperature - Sampling temperature (0-2)
  • isR1FormatRequired - Enable R1 message format
string
For reasoning models (o1/o3/o4). Options:
  • low - Faster, less thorough
  • medium - Balanced
  • high - Slower, more thorough
string
Azure OpenAI API version. Defaults to 2024-10-01-preview
boolean
default:"false"
Use Azure Active Directory authentication instead of API key
Record<string, string>
Additional HTTP headers for requests

Basic Setup

OpenAI Standard

Azure OpenAI

DeepSeek Reasoner on Azure

Reasoning Models

OpenAI’s o1, o3, and o4 models support reasoning effort control:

Reasoning Model Behavior

From openai.ts:129-134:
Reasoning models use developer roleWhen using o1/o3/o4 models:
  • System prompt sent as developer role instead of system
  • Temperature is automatically set to undefined (not supported)
  • Messages use special reasoning format

R1 Format Models

Some models (like DeepSeek Reasoner) require R1 message format:

Temperature Control

Temperature defaults to 0 for deterministic output unless specified.Reasoning models (o1/o3/o4) ignore temperature - it’s automatically set to undefined.

Token Limits

If not specified, maxTokens is undefined (uses model’s default).

Tool Calling

Streaming Response

The handler processes streaming chunks:

Text Delta

Reasoning Content

Tool Calls

Usage Statistics

Prompt Caching

OpenAI supports prompt caching (reported in usage stats):

Custom Headers

Azure Regional Endpoints

The handler auto-detects Azure regions for authentication:

Error Handling

Model Information

Implementation Reference

Source: ~/workspace/source/src/core/api/providers/openai.ts Key features:
  • Auto-detects Azure vs standard OpenAI
  • Handles reasoning models (o1/o3/o4) with developer role
  • Supports R1 format for DeepSeek Reasoner
  • Azure Identity authentication
  • Regional Azure endpoints
  • Streaming with tool calls

Common Patterns

Switch Between Models

Cost Tracking

Next Steps

Anthropic Provider

Configure Claude models

OpenRouter Provider

Access multiple providers

Provider Overview

View all providers

Custom Provider

Build your own