api

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package api implements the LLM gateway against a direct Anthropic-compatible HTTP endpoint.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoAPIKey = errors.New("api: an API key is required")

ErrNoAPIKey is returned when no key is configured.

Functions

This section is empty.

Types

type AuthStyle

type AuthStyle string

AuthStyle selects how the API key is presented.

const (
	AuthStyleAnthropic AuthStyle = "x-api-key"
	AuthStyleBearer    AuthStyle = "bearer"
)

type Gateway

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

Gateway is a direct-API LLM gateway.

func New

func New(o Options) (*Gateway, error)

New returns a gateway.

func (*Gateway) Complete

func (g *Gateway) Complete(ctx context.Context, r llm.Req) (llm.Res, error)

Complete implements llm.Gateway.

func (*Gateway) ModelFor

func (g *Gateway) ModelFor(c llm.ModelClass) string

ModelFor implements llm.Gateway.

type Options

type Options struct {
	BaseURL     string
	APIKey      string
	StrongModel string
	FastModel   string
	AuthStyle   AuthStyle
	Cache       llm.Cache
	HTTPClient  *http.Client
	MaxRetries  int
	Sleep       func(time.Duration)
}

Options configures the gateway.

Jump to

Keyboard shortcuts

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