Skip to main content

What are Providers?

Providers are the abstraction layer in Goose that connects to different AI model services. Each provider implements the Provider trait, which standardizes how Goose communicates with various AI backends like Anthropic, OpenAI, Databricks, and Ollama.

Provider Trait

All providers implement the Provider trait, which defines the core interface:

Key Methods

stream() The primary method for streaming responses from the AI model. Returns a MessageStream that yields partial messages as they’re generated. complete() A convenience method that collects the entire stream into a single message and usage information. Most implementations delegate to stream() and collect the results. get_model_config() Returns the current model configuration including model name, temperature, and other parameters. fetch_supported_models() Queries the provider’s API to get a list of available models.

Provider Metadata

Each provider defines metadata through the ProviderDef trait:

Configuration Keys

Providers specify their required configuration through ConfigKey:

Model Configuration

The ModelConfig struct controls model behavior:

Usage and Pricing

Providers track token usage through ProviderUsage:

Built-in Providers

Goose includes several built-in providers:
  • Anthropic - Claude models (Sonnet, Opus, Haiku)
  • OpenAI - GPT-4, GPT-4o, and other OpenAI models
  • Databricks - Models on Databricks AI Gateway
  • Ollama - Local open-source models
  • Azure OpenAI - OpenAI models hosted on Azure
  • Google Vertex AI - Google’s AI models
  • AWS Bedrock - Amazon’s model marketplace

Custom Providers

You can create custom providers in two ways:
  1. Declarative Providers - JSON configuration files for OpenAI-compatible APIs
  2. Rust Implementation - Implement the Provider trait for full control
See the Custom Providers guide for details.

Provider Registry

Providers are registered at startup and can be retrieved by name:

Error Handling

Providers use the ProviderError enum for error handling:

Retry Configuration

Providers support configurable retry logic:

Next Steps