Skip to main content

Overview

OpenAI is one of the leading AI providers, offering powerful language models (GPT-4, GPT-3.5, o1), image generation (DALL-E), speech (Whisper, TTS), and more. Portkey provides full support for all OpenAI capabilities. Base URL: https://api.openai.com/v1

Supported Features

  • ✅ Chat Completions (including streaming)
  • ✅ Completions (legacy)
  • ✅ Embeddings
  • ✅ Image Generation (DALL-E)
  • ✅ Image Editing
  • ✅ Text-to-Speech (TTS)
  • ✅ Speech-to-Text (Whisper transcription)
  • ✅ Audio Translation
  • ✅ Realtime API (WebSocket)
  • ✅ Function Calling & Tools
  • ✅ Vision (GPT-4 Vision)
  • ✅ Batch API
  • ✅ Fine-tuning
  • ✅ File Operations

Quick Start

Chat Completions

Streaming Responses

Configuration Options

Headers

Advanced Features

Function Calling

Vision (GPT-4 Vision)

Embeddings

Image Generation (DALL-E)

Text-to-Speech

Speech-to-Text (Whisper)

Fallback Configuration

Use Anthropic as fallback for OpenAI:

Load Balancing

Distribute requests between OpenAI and Azure OpenAI:

Batch API

Error Handling

Request & Response Format

Request

Response

Best Practices

  1. Use streaming for long responses to improve user experience
  2. Implement retry logic with exponential backoff for rate limits
  3. Cache embeddings to reduce costs and latency
  4. Use gpt-4o-mini for high-volume, simpler tasks
  5. Set max_tokens to control costs and response length
  6. Use system messages to guide model behavior consistently
  7. Implement fallbacks to other providers for reliability

Pricing

For up-to-date OpenAI pricing, visit:

OpenAI Pricing

View detailed pricing for all OpenAI models

Azure OpenAI

Use OpenAI models through Azure

Fallback Routing

Set up fallbacks from OpenAI

Caching

Cache OpenAI responses

Function Calling

Advanced function calling guide