provider

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2026 License: AGPL-3.0 Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UnknownRoute = errors.New("unknown route")

Functions

This section is empty.

Types

type Anthropic

type Anthropic struct {
	// contains filtered or unexported fields
}

Anthropic allows for interactions with the Anthropic API.

func NewAnthropic

func NewAnthropic(cfg config.Anthropic, bedrockCfg *config.AWSBedrock) *Anthropic

func (*Anthropic) AuthHeader

func (p *Anthropic) AuthHeader() string

func (*Anthropic) BaseURL

func (p *Anthropic) BaseURL() string

func (*Anthropic) BridgedRoutes

func (p *Anthropic) BridgedRoutes() []string

func (*Anthropic) CircuitBreakerConfig

func (p *Anthropic) CircuitBreakerConfig() *config.CircuitBreaker

func (*Anthropic) CreateInterceptor

func (p *Anthropic) CreateInterceptor(w http.ResponseWriter, r *http.Request, tracer trace.Tracer) (_ intercept.Interceptor, outErr error)

func (*Anthropic) InjectAuthHeader

func (p *Anthropic) InjectAuthHeader(headers *http.Header)

func (*Anthropic) Name

func (p *Anthropic) Name() string

func (*Anthropic) PassthroughRoutes

func (p *Anthropic) PassthroughRoutes() []string

type Copilot

type Copilot struct {
	// contains filtered or unexported fields
}

Copilot implements the Provider interface for GitHub Copilot. Unlike other providers, Copilot uses per-user API keys that are passed through the request headers rather than configured statically.

func NewCopilot

func NewCopilot(cfg config.Copilot) *Copilot

func (*Copilot) AuthHeader

func (p *Copilot) AuthHeader() string

func (*Copilot) BaseURL

func (p *Copilot) BaseURL() string

func (*Copilot) BridgedRoutes

func (p *Copilot) BridgedRoutes() []string

func (*Copilot) CircuitBreakerConfig

func (p *Copilot) CircuitBreakerConfig() *config.CircuitBreaker

func (*Copilot) CreateInterceptor

func (p *Copilot) CreateInterceptor(_ http.ResponseWriter, r *http.Request, tracer trace.Tracer) (_ intercept.Interceptor, outErr error)

func (*Copilot) InjectAuthHeader

func (p *Copilot) InjectAuthHeader(_ *http.Header)

InjectAuthHeader is a no-op for Copilot. Copilot uses per-user tokens passed in the original Authorization header, rather than a global key configured at the provider level. The original Authorization header flows through untouched from the client.

func (*Copilot) Name

func (p *Copilot) Name() string

func (*Copilot) PassthroughRoutes

func (p *Copilot) PassthroughRoutes() []string

type OpenAI

type OpenAI struct {
	// contains filtered or unexported fields
}

OpenAI allows for interactions with the OpenAI API.

func NewOpenAI

func NewOpenAI(cfg config.OpenAI) *OpenAI

func (*OpenAI) AuthHeader

func (p *OpenAI) AuthHeader() string

func (*OpenAI) BaseURL

func (p *OpenAI) BaseURL() string

func (*OpenAI) BridgedRoutes

func (p *OpenAI) BridgedRoutes() []string

func (*OpenAI) CircuitBreakerConfig

func (p *OpenAI) CircuitBreakerConfig() *config.CircuitBreaker

func (*OpenAI) CreateInterceptor

func (p *OpenAI) CreateInterceptor(w http.ResponseWriter, r *http.Request, tracer trace.Tracer) (_ intercept.Interceptor, outErr error)

func (*OpenAI) InjectAuthHeader

func (p *OpenAI) InjectAuthHeader(headers *http.Header)

func (*OpenAI) Name

func (p *OpenAI) Name() string

func (*OpenAI) PassthroughRoutes

func (p *OpenAI) PassthroughRoutes() []string

PassthroughRoutes define the routes which are not currently intercepted but must be passed through to the upstream. The /v1/completions legacy API is deprecated and will not be passed through. See https://platform.openai.com/docs/api-reference/completions.

type Provider

type Provider interface {
	// Name returns the provider's name.
	Name() string
	// BaseURL defines the base URL endpoint for this provider's API.
	BaseURL() string

	// CreateInterceptor starts a new [Interceptor] which is responsible for intercepting requests,
	// communicating with the upstream provider and formulating a response to be sent to the requesting client.
	CreateInterceptor(http.ResponseWriter, *http.Request, trace.Tracer) (intercept.Interceptor, error)

	// BridgedRoutes returns a slice of [http.ServeMux]-compatible routes which will have special handling.
	// See https://pkg.go.dev/net/http#hdr-Patterns-ServeMux.
	BridgedRoutes() []string
	// PassthroughRoutes returns a slice of whitelisted [http.ServeMux]-compatible* routes which are
	// not currently intercepted and must be handled by the upstream directly.
	//
	// * only path routes can be specified, not ones containing HTTP methods. (i.e. GET /route).
	// By default, these passthrough routes will accept any HTTP method.
	PassthroughRoutes() []string

	// AuthHeader returns the name of the header which the provider expects to find its authentication
	// token in.
	AuthHeader() string
	// InjectAuthHeader allows [Provider]s to set its authentication header.
	InjectAuthHeader(*http.Header)

	// CircuitBreakerConfig returns the circuit breaker configuration for the provider.
	CircuitBreakerConfig() *config.CircuitBreaker
}

Provider describes an AI provider client's behaviour. Provider clients are responsible for interacting with upstream AI providers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL