This guide provides detailed configuration instructions for each supported AI provider in the Nexora Agent Mode system.
All providers follow a consistent configuration pattern in the .env file:
<PROVIDER>_API_KEY=<your_key>
<PROVIDER>_MODEL=<model_name>
<PROVIDER>_ENABLED=<true|false>
Additional provider-specific settings may be required.
OPENAI_API_KEY=sk-proj-...
OPENAI_MODEL=gpt-4
OPENAI_ENABLED=true
gpt-4: Most capable model, best for complex tasksgpt-4-turbo-preview: Faster GPT-4 variantgpt-3.5-turbo: Fast and cost-effectivegpt-3.5-turbo-16k: Extended context windowFree Tier:
Pay-as-you-go:
401: Invalid API key429: Rate limit exceeded500: OpenAI server error503: Service temporarily unavailableIssue: “Invalid API key”
# Verify key format (should start with sk-)
echo $OPENAI_API_KEY
# Test with curl
curl https://api.openai.com/v1/models \
-H "Authorization: Bearer $OPENAI_API_KEY"
Issue: Rate limit errors
# Increase timeout and retries
MAX_RETRIES=5
REQUEST_TIMEOUT=60
# Or upgrade account tier
GOOGLE_API_KEY=AIza...
GEMINI_MODEL=gemini-pro
GEMINI_ENABLED=true
gemini-pro: Text-only generationgemini-pro-vision: Multimodal (text + images)gemini-ultra: Most capable (when available)Free Tier:
Paid Tier:
Gemini includes built-in safety filters that may block certain content:
# Custom safety settings (future enhancement)
generation_config = genai.types.GenerationConfig(
temperature=0.7,
max_output_tokens=1000,
)
safety_settings = [
{"category": "HARM_CATEGORY_HARASSMENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
{"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_MEDIUM_AND_ABOVE"},
]
400: Invalid request (safety filters, invalid input)401: Invalid API key429: Quota exceeded500: Internal server errorIssue: “API key not valid”
# Verify API key is enabled
# Check Google Cloud Console > APIs & Services > Credentials
# Ensure Generative Language API is enabled
# Google Cloud Console > APIs & Services > Enabled APIs
Issue: Safety filter blocks
# Review prompt content
# Gemini has stricter safety filters than some providers
# Rephrase prompt or use different provider
Note: xAI Grok API access may be limited or require application.
XAI_API_KEY=xai-...
XAI_ENDPOINT=https://api.x.ai/v1
XAI_MODEL=grok-1
XAI_ENABLED=true
grok-1: Primary Grok modelgrok-beta: Beta version with latest featuresDetails depend on xAI account tier:
401: Authentication failed429: Rate limit exceeded500: Server error503: Service unavailableIssue: Connection errors
# Verify endpoint URL
echo $XAI_ENDPOINT
# Test connectivity
curl -I $XAI_ENDPOINT
# Check xAI status page for outages
Issue: Authentication failed
# Verify API key format
# Contact xAI support if issues persist
The Generic HTTP provider allows integration with any AI API that follows standard HTTP/JSON patterns, including:
GENERIC_API_KEY=your_api_key_here
GENERIC_ENDPOINT=https://api.example.com/v1/completions
GENERIC_ENABLED=true
The generic provider sends POST requests with:
{
"prompt": "User's prompt text",
"temperature": 0.7,
"max_tokens": 1000
}
Headers:
Authorization: Bearer <GENERIC_API_KEY>
Content-Type: application/json
The provider looks for response text in these fields (in order):
textresponseoutput{
"text": "Generated response text"
}
or
{
"response": "Generated response text"
}
GENERIC_API_KEY=sk-ant-...
GENERIC_ENDPOINT=https://api.anthropic.com/v1/messages
GENERIC_ENABLED=true
Note: Claude has a different API format. Consider creating a dedicated provider for production use.
GENERIC_API_KEY=not_required
GENERIC_ENDPOINT=http://localhost:11434/api/generate
GENERIC_ENABLED=true
GENERIC_API_KEY=<cohere_api_key>
GENERIC_ENDPOINT=https://api.cohere.ai/v1/generate
GENERIC_ENABLED=true
Custom Headers:
response = agent.execute(
prompt="Your prompt",
provider="generic_http",
headers={
"X-Custom-Header": "value",
"X-Another-Header": "value"
}
)
Custom Payload:
response = agent.execute(
prompt="Your prompt",
provider="generic_http",
payload={
"model": "custom-model",
"prompt": "Your prompt",
"custom_param": "value"
}
)
GET Requests:
response = agent.execute(
prompt="Your prompt",
provider="generic_http",
method="GET"
)
Issue: “Provider not configured”
# Verify endpoint is accessible
curl -I $GENERIC_ENDPOINT
# Test authentication
curl -X POST $GENERIC_ENDPOINT \
-H "Authorization: Bearer $GENERIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt": "test"}'
Issue: “No response text found”
# Check response format from your API
# Ensure it includes "text", "response", or "output" field
# Example: test your API directly
curl -X POST $GENERIC_ENDPOINT \
-H "Authorization: Bearer $GENERIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt": "hello"}' | jq .
Development:
DEFAULT_PROVIDER=openai
FALLBACK_PROVIDERS=google_gemini
OPENAI_ENABLED=true
GEMINI_ENABLED=true
XAI_ENABLED=false
GENERIC_ENABLED=false
Production (High Availability):
DEFAULT_PROVIDER=openai
FALLBACK_PROVIDERS=google_gemini,xai_grok
OPENAI_ENABLED=true
GEMINI_ENABLED=true
XAI_ENABLED=true
GENERIC_ENABLED=false
Cost-Optimized:
DEFAULT_PROVIDER=google_gemini
FALLBACK_PROVIDERS=openai
OPENAI_MODEL=gpt-3.5-turbo
GEMINI_ENABLED=true
OPENAI_ENABLED=true
Choose OpenAI when:
Choose Google Gemini when:
Choose xAI Grok when:
Choose Generic/Custom when:
.env files
echo ".env" >> .gitignore
.env.dev # Development
.env.staging # Staging
.env.prod # Production
REQUEST_TIMEOUT=30 # Balance speed and reliability
MAX_RETRIES=3 # Prevent excessive retries
OPENAI_ENABLED=true
GEMINI_ENABLED=true
FALLBACK_PROVIDERS=google_gemini,xai_grok
nexora-agent test-provider --provider openai
nexora-agent test-provider --provider google_gemini
OPENAI_MODEL=gpt-3.5-turbo
response = agent.execute(prompt, max_tokens=500)
# Check provider status
nexora-agent status
# Test each enabled provider
nexora-agent test-provider --provider openai
nexora-agent test-provider --provider google_gemini
# Test fallback chain
# (Temporarily disable default provider to test fallback)
Proper provider configuration is crucial for reliable operation of the Nexora AI Agent Mode system. Follow this guide to configure each provider correctly, implement best practices, and ensure high availability.
For more information:
/docs/agent-mode.md/docs/architecture.md/docs/deployment.md