Configuring API Providers
Configure Forge to work with your preferred AI provider. This guide covers provider setup, priority handling, environment file merging, and provider-specific features.
Supported AI Providers
Forge supports multiple AI providers, each with unique capabilities and pricing models:
Provider Overview
- Forge Provider (
FORGE_KEY
): Forgecode's managed service with optimized models - OpenRouter (
OPENROUTER_API_KEY
): Access to 300+ models from multiple providers - OpenAI (
OPENAI_API_KEY
): Official OpenAI models (GPT-4, o3-mini, etc.) - Anthropic (
ANTHROPIC_API_KEY
): Claude models (Claude 3.7 Sonnet, etc.) - Google Vertex AI: Google's enterprise AI platform with Claude and Gemini models
- Groq: Ultra-fast inference with optimized models like DeepSeek R1
- Amazon Bedrock: AWS managed AI service with multiple model providers
- OpenAI-Compatible Providers: Any provider following OpenAI API format
Environment Configuration
Create Environment File
Create a .env
file to store your API credentials. You can place this file in multiple locations:
# In your home directory (global configuration)
touch ~/.env
# In your project directory (project-specific)
touch .env
# In any parent directory of your project
touch ../../../.env
Forge will automatically detect and merge environment files from multiple locations.
Add API Credentials
Add your preferred provider's API key to the .env
file:
# Choose one or multiple providers
# Forge Provider (Forgecode's managed service)
FORGE_KEY=your_forge_api_key_here
# OpenRouter (recommended for model variety)
OPENROUTER_API_KEY=your_openrouter_key_here
# Official OpenAI
OPENAI_API_KEY=your_openai_key_here
# Official Anthropic
ANTHROPIC_API_KEY=your_anthropic_key_here
# Google Vertex AI
PROJECT_ID=your_project_id
LOCATION=your_location
OPENAI_API_KEY=your_vertex_ai_key
OPENAI_URL=https://${LOCATION}-aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/${LOCATION}/endpoints/openapi
# Groq
OPENAI_API_KEY=your_groq_api_key
OPENAI_URL=https://api.groq.com/openai/v1
# Amazon Bedrock (requires Bedrock Access Gateway)
OPENAI_API_KEY=your_bedrock_gateway_api_key
OPENAI_URL=your_bedrock_gateway_base_url
# OpenAI-Compatible Providers
OPENAI_API_KEY=your_provider_api_key
OPENAI_URL=your_provider_url
Where to get API keys:
- Forge Provider - Sign up for Antinomy account
- OpenRouter - Aggregated access to multiple models
- OpenAI - Official OpenAI platform
- Anthropic - Official Anthropic console
- Google Vertex AI - Google Cloud AI platform
- Groq - Ultra-fast inference platform
- Amazon Bedrock - AWS managed AI service
Example setup with Forge Provider (recommended):
# ~/.env
FORGE_KEY=your_forge_api_key_here
Example setup with OpenRouter:
# ~/.env
OPENROUTER_API_KEY=your_openrouter_key_here
Example setup with Groq:
# ~/.env
OPENAI_API_KEY=your_groq_api_key
OPENAI_URL=https://api.groq.com/openai/v1
Example setup with Amazon Bedrock:
# ~/.env
OPENAI_API_KEY=your_bedrock_gateway_api_key
OPENAI_URL=your_bedrock_gateway_base_url
Note: Amazon Bedrock requires setting up the Bedrock Access Gateway first.
Verify Configuration
Test your provider configuration by running Forge:
forge --version
Forge will automatically detect and use the highest priority provider available.
Provider Priority & Environment Merging
Priority Order
When multiple API keys are configured, Forge uses this priority order:
FORGE_KEY
- Highest priority (Forgecode's provider)OPENROUTER_API_KEY
- Second priority (multiple models)OPENAI_API_KEY
- Third priority (official OpenAI)ANTHROPIC_API_KEY
- Lowest priority (official Anthropic)
Environment File Merging
Forge searches for .env
files in this order and merges them:
- Current working directory (
.env
) - Parent directories (recursively up to root)
- Home directory (
~/.env
)
Merge behavior:
- Variables in closer directories override those in parent directories
- Project-level
.env
takes precedence over global~/.env
- First found variable wins (no overriding within same file)
Example scenario:
# ~/.env (global)
OPENAI_API_KEY=global_openai_key
ANTHROPIC_API_KEY=global_anthropic_key
# /project/.env (project-specific)
FORGE_KEY=project_forge_key
OPENAI_API_KEY=project_openai_key
# Result: Forge uses project_forge_key (highest priority)
# OPENAI_API_KEY from project overrides global
# ANTHROPIC_API_KEY from global is still available
Next Steps
Provider configuration complete! Forge will automatically use your configured provider based on the priority order and environment setup.