Selecting a provider
Set the active provider in yourconfig/ai-translations.php file:
.env file:
The default provider is Gemini, which offers a good balance of speed, quality, and cost.
Provider configuration
- OpenAI
- Anthropic
- Gemini
OpenAI setup
OpenAI provides high-quality translations with models like GPT-4 and GPT-5.Environment variables
Add these variables to your.env file:.env
Configuration
Configure OpenAI inconfig/ai-translations.php:Available models
The primary model used for standard translations. Recommended options:
gpt-5-mini- Latest efficient model (default)gpt-4o- Previous generation flagship modelgpt-4-turbo- Faster GPT-4 variant
The model used when running with the
--fast flag. Optimized for speed and cost:gpt-5-nano- Ultra-fast model (default)gpt-4o-mini- Compact but capable
Your OpenAI API key. Get one from platform.openai.com.
Getting an API key
- Sign up at platform.openai.com
- Navigate to API keys section
- Create a new secret key
- Add the key to your
.envfile
Fast mode
When you run the translate command with the--fast flag, the package automatically switches to the configured fast_model:
- More cost-effective
- Faster to respond
- Slightly less precise for complex translations
Use fast mode for large translation jobs or when iterating quickly. Use standard models for production translations where quality is critical.
Model selection best practices
For production translations
- OpenAI:
gpt-5-miniorgpt-4o - Anthropic:
claude-sonnet-4-5orclaude-opus-4 - Gemini:
gemini-flash-latestorgemini-pro-latest
For development or large batches
- OpenAI:
gpt-5-nanoorgpt-4o-mini - Anthropic:
claude-haiku-4-5 - Gemini:
gemini-flash-lite-latest
Troubleshooting
Invalid API key error
If you receive an authentication error:- Verify your API key is correctly set in
.env - Ensure there are no extra spaces or quotes around the key
- Check that you’ve cleared the config cache:
php artisan config:clear - Verify your API key is active in the provider’s console
Provider not found
If you see a “Invalid provider” error:- Verify the
providersetting inconfig/ai-translations.php - Ensure it’s one of:
openai,anthropic, orgemini - Clear the config cache:
php artisan config:clear
Next steps
Configure languages
Set up which languages to translate