Overview
The OpenAI provider offers comprehensive support for all OpenAI services including GPT models, embeddings, function calling, and structured output. It’s the most feature-complete provider in the SDK.Quick Start
Available Models
Chat Models
|
gpt-4o-mini | Latest GPT-4 model | 128k | 15/1M output |
Embedding Models
Basic Usage
Text Generation
Streaming
With System Instructions
Advanced Features
Structured Output
OpenAI supports native structured output withresponse_format="json_object":
Function Calling
Embeddings
Vision Models
Configuration
API Key
Set your OpenAI API key:Default Parameters
Configure default parameters for all requests:Organization
For team accounts:Parameters
Common Parameters
Generation Parameters
Embedding Parameters
Error Handling
Rate Limiting
Token Limits
Best Practices
1. Model Selection
Choose the right model for your use case:2. Cost Optimization
Monitor and optimize costs:3. Prompt Engineering
Use clear, specific prompts:4. Streaming for Long Responses
Use streaming for better user experience:5. Structured Output for Reliability
Use structured output for consistent results:Troubleshooting
Common Issues
-
Invalid API Key
- Check your API key is correct
- Ensure you have sufficient credits
-
Model Not Found
- Verify model name spelling
- Check if model is available in your region
-
Rate Limiting
- Implement exponential backoff
- Consider upgrading your plan
-
Token Limit Exceeded
- Reduce input length
- Use a model with higher token limits