When to Create a Custom Provider
Consider creating a custom provider when:- Your organization has a proprietary LLM deployment
- You’re using an OpenAI-compatible API that isn’t built-in
- You need special authentication or request preprocessing
- You want to add custom retry logic or error handling
- You’re using a provider with non-standard streaming formats
Before building a custom provider, check if your provider is OpenAI or Anthropic API-compatible. If so, the declarative approach is much simpler.
Declarative Providers (Recommended)
For OpenAI-compatible APIs, create a JSON configuration file:Basic Structure
Create~/.config/goose/providers/my-provider.json:
Configuration Fields
string
required
Unique identifier for the provider
string
required
API format to use:
openai, anthropic, or ollamastring
required
Base URL for API requests
array
required
List of available models
string
required
Model identifier
integer
Maximum context size in tokens
boolean
default:"true"
Whether the model supports tool/function calling
boolean
default:"false"
Whether the model can process images
object
Authentication configuration
string
Authentication method:
header, query, or oauthReal-World Examples
- Together.ai
- OpenRouter
- vLLM (Self-Hosted)
Using Your Provider
After creating the configuration file, use it:~/.config/goose/providers/.
Programmatic Provider Implementation
For providers with non-standard APIs or special requirements, implement theProvider trait in Rust:
Provider Trait Overview
Basic Implementation
Create a custom provider incrates/goose/src/providers/my_provider.rs:
Register the Provider
Add your provider to the registry incrates/goose/src/providers/provider_registry.rs:
Advanced Features
OAuth Authentication
For providers requiring OAuth:Retry Logic
Implement custom retry behavior:Model Discovery
Allow dynamic model listing:Testing Your Provider
Unit Tests
Test provider functionality:Integration Tests
Test with goose:Next Steps
Provider Interface
Complete guide to implementing the Provider trait
Declarative Providers
JSON configuration reference for OpenAI-compatible providers
OAuth Providers
Implement OAuth authentication flows
Providers Overview
API reference for the Provider trait