What are Declarative Providers?
Declarative providers are JSON configuration files that define:- Provider metadata (name, description)
- API endpoint configuration
- Supported models and their capabilities
- Authentication requirements
- Protocol format (OpenAI-compatible, etc.)
Configuration File Structure
Declarative providers are located incrates/goose/src/providers/declarative/.
Basic Structure
Field Reference
Required Fields
name (string)- Unique identifier for the provider
- Used in configuration and CLI
- Must be lowercase, alphanumeric with underscores
- Protocol/format the provider uses
- Currently supported:
"openai" - Determines how requests are formatted
- Human-readable name shown in UIs
- Can include spaces and special characters
- Brief description of the provider
- Shown in provider selection UIs
- Environment variable name for API key
- Convention:
PROVIDER_API_KEYformat
- API endpoint URL
- For OpenAI-compatible providers, include full path to chat completions
- List of supported models
- See Model Configuration
- Whether the provider supports streaming responses
- Most modern providers support this
Model Configuration
Each model in themodels array defines:
Model Fields
name (string, required)- Model identifier used in API requests
- Exact string the provider expects
- Maximum context window size in tokens
- Used for context management
- Maximum output tokens per request
- Used to limit response length
- Cost per input token in USD
- Used for cost estimation
- Cost per output token in USD
- Used for cost estimation
Complete Examples
Groq Provider
Mistral Provider
DeepSeek Provider
Local Model Provider
Creating a New Declarative Provider
1. Create Configuration File
Create a new JSON file incrates/goose/src/providers/declarative/:
2. Define Configuration
3. Rebuild Goose
The provider is automatically loaded at build time:4. Configure and Use
Set the API key:OpenAI-Compatible APIs
Many providers offer OpenAI-compatible APIs. For these:- Set
"engine": "openai" - Use the provider’s base URL
- Ensure model names match what the provider expects
- Together AI
- Fireworks AI
- Anyscale Endpoints
- Modal
- Replicate (with OpenAI compatibility)
Advanced Configuration
Multiple Model Variants
Include all model variants with accurate limits:Special Model Naming
Some providers use prefixes or special characters:Cost Tracking
Include accurate pricing for cost estimation:- Track token usage
- Estimate costs per request
- Show cumulative costs
Validation
Testing Your Provider
After creating a declarative provider:Common Issues
Provider not found- Ensure JSON file is in
crates/goose/src/providers/declarative/ - Rebuild:
cargo build - Check provider name matches filename (without
.json)
- Verify environment variable name matches
api_key_env - Check API key is set:
echo $MYPROVIDER_API_KEY - Ensure API key format is correct
- Verify model name exactly matches provider’s API
- Check provider documentation for exact model identifiers
- Reduce
context_limitif requests fail - Check provider’s actual model limits
- Some providers report limits differently
Limitations
Declarative providers currently:- Only support OpenAI-compatible APIs
- Cannot implement custom OAuth flows
- Cannot handle complex authentication schemes
- Cannot customize request/response transformation
Contributing Declarative Providers
To add a provider to Goose:- Create the JSON configuration file
- Test thoroughly
- Document model capabilities accurately
- Submit a PR to the Goose repository
- Include example usage in PR description
Existing Declarative Providers
Goose includes these declarative providers:- Groq - Fast inference
- Mistral - Mistral AI models
- DeepSeek - DeepSeek models
- Cerebras - Cerebras inference
- Moonshot - Moonshot AI
- Kimi - Kimi models
- LM Studio - Local model hosting
- OVHcloud - OVHcloud AI endpoints
crates/goose/src/providers/declarative/ for complete configurations.
Next Steps
- Learn about OAuth Providers
- Implement Custom Providers
- Read about Provider Architecture