Versions in this module Expand all Collapse all v0 v0.1.1 Jun 25, 2026 v0.1.0 Jun 25, 2026 Changes in this version + var ErrKeyInvalid = errors.New("ai-gateway: invalid or revoked API key") + var ErrModelNotAllowed = errors.New("ai-gateway: model not allowed for this key") + var ErrNoProvider = errors.New("ai-gateway: no provider could handle the request") + var ErrQuotaExceeded = errors.New("ai-gateway: spend quota exceeded") + var ErrRateLimited = errors.New("ai-gateway: rate limit exceeded") + func RegisterProvider(p Provider) + type Gateway struct + func FromKernel(k *togo.Kernel) (*Gateway, bool) + func New() *Gateway + func (g *Gateway) Complete(ctx context.Context, rawKey string, req Request) (Response, error) + func (g *Gateway) CreateKey(name string, k Key) (raw string, rec *Key) + func (g *Gateway) Keys() []*Key + func (g *Gateway) Prompts() *promptStore + func (g *Gateway) RenderPrompt(name string, vars map[string]string) (string, bool) + func (g *Gateway) Revoke(id string) bool + func (g *Gateway) SetPrice(model string, p Price) + func (g *Gateway) Usage(keyID string) []UsageRecord + type Key struct + AllowedModels []string + CreatedAt time.Time + HardCap float64 + ID string + MonthlyCap float64 + Name string + RatePerMin int + Revoked bool + Spend float64 + type Message struct + Content string + Role string + type Price struct + Input float64 + Output float64 + type Provider interface + Complete func(ctx context.Context, req Request) (Response, error) + Name func() string + type Request struct + MaxTokens int + Messages []Message + Model string + Temperature float64 + type Response struct + Cached bool + Content string + Cost float64 + InputTokens int + Model string + OutputTokens int + Provider string + type UsageRecord struct + At time.Time + Cached bool + Cost float64 + Input int + KeyID string + Model string + Output int