Skip to main content
Goose’s provider system allows integration with any LLM service. This guide explains how to implement the Provider trait and integrate new LLM providers.

Provider Trait Overview

All providers implement the Provider trait defined in crates/goose/src/providers/base.rs:456.

Core Methods

Key Types

MessageStream - Stream of message chunks:
ProviderUsage - Token usage information:

Implementing a Basic Provider

1. Define Provider Struct

2. Implement Provider Trait

3. Implement ProviderDef

Message Format Conversion

Convert Goose’s internal message format to provider-specific format:

Streaming Implementation

Process Server-Sent Events (SSE) stream:

Tool Support

Convert MCP tools to provider format:
Handle tool calls in responses:

Advanced Features

OAuth Support

Implement OAuth authentication:

Model Discovery

Fetch available models:

Retry Logic

Configure retry behavior:

Session Naming

Customize session name generation:

Error Handling

Use ProviderError for provider-specific errors:
Example:

Testing Providers

Unit Tests

Integration Tests

Registration

Register your provider in crates/goose/src/providers/provider_registry.rs:

Next Steps