Skip to main content
While goose supports 30+ LLM providers out of the box, you may need to integrate with a custom or proprietary provider. Goose offers two approaches: declarative configuration for OpenAI-compatible APIs, and full Rust trait implementation for complete control.

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.
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 ollama
string
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 oauth

Real-World Examples

Set your API key:

Using Your Provider

After creating the configuration file, use it:
Or configure interactively:
Goose automatically discovers provider JSON files in ~/.config/goose/providers/.

Programmatic Provider Implementation

For providers with non-standard APIs or special requirements, implement the Provider trait in Rust:

Provider Trait Overview

Basic Implementation

Create a custom provider in crates/goose/src/providers/my_provider.rs:

Register the Provider

Add your provider to the registry in crates/goose/src/providers/provider_registry.rs:

Advanced Features

OAuth Authentication

For providers requiring OAuth:
See the OAuth Providers guide for a complete implementation.

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