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
Popular Models
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
- Use streaming for long responses to improve user experience
- Implement retry logic with exponential backoff for rate limits
- Cache embeddings to reduce costs and latency
- Use gpt-4o-mini for high-volume, simpler tasks
- Set max_tokens to control costs and response length
- Use system messages to guide model behavior consistently
- Implement fallbacks to other providers for reliability
Pricing
For up-to-date OpenAI pricing, visit:OpenAI Pricing
View detailed pricing for all OpenAI models
Related Resources
Azure OpenAI
Use OpenAI models through Azure
Fallback Routing
Set up fallbacks from OpenAI
Caching
Cache OpenAI responses
Function Calling
Advanced function calling guide