gateway

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package gateway provides multi-provider LLM gateway.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnthropicProvider

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

AnthropicProvider implements Anthropic API.

func NewAnthropicProvider

func NewAnthropicProvider(apiKey string) *AnthropicProvider

NewAnthropicProvider creates Anthropic provider.

func (*AnthropicProvider) Compress

func (*AnthropicProvider) HealthCheck

func (p *AnthropicProvider) HealthCheck() error

func (*AnthropicProvider) Name

func (p *AnthropicProvider) Name() string

type CompressionRequest

type CompressionRequest struct {
	Content     string
	Mode        string
	MaxTokens   int
	ContextType string
}

CompressionRequest represents a compression request.

type CompressionResponse

type CompressionResponse struct {
	Compressed   string
	TokensSaved  int
	ProviderUsed string
	LatencyMs    int64
}

CompressionResponse represents a compression response.

type Gateway

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

Gateway manages multiple providers with fallback.

func NewGateway

func NewGateway() *Gateway

NewGateway creates a new gateway.

func (*Gateway) AddProvider

func (g *Gateway) AddProvider(p Provider)

AddProvider adds a provider to the gateway.

func (*Gateway) Compress

Compress compresses content with fallback.

func (*Gateway) HealthChecks

func (g *Gateway) HealthChecks() map[string]error

HealthChecks runs health checks on all providers.

func (*Gateway) SetQuota

func (g *Gateway) SetQuota(provider string, limit int64)

SetQuota sets the quota for a provider.

type OpenAIProvider

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

OpenAIProvider implements OpenAI API.

func NewOpenAIProvider

func NewOpenAIProvider(apiKey string) *OpenAIProvider

NewOpenAIProvider creates OpenAI provider.

func (*OpenAIProvider) Compress

func (*OpenAIProvider) HealthCheck

func (p *OpenAIProvider) HealthCheck() error

func (*OpenAIProvider) Name

func (p *OpenAIProvider) Name() string

type Provider

type Provider interface {
	Name() string
	Compress(ctx context.Context, req *CompressionRequest) (*CompressionResponse, error)
	HealthCheck() error
}

Provider interface for LLM providers.

type QuotaManager

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

QuotaManager manages usage quotas.

Jump to

Keyboard shortcuts

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