Help us shape the future of Go! Take the 2026 Go Developer Survey

model

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package model is the model-serving connector for the anthropic, openai and model adapters. The platform proxies seats' model requests through it and injects the credential, so no key enters a sandbox (§5.2, ADR-0001).

A connection's endpoint is its API base, usually ending in /v1 (https://api.openai.com/v1). Seats address the proxy with the API path below /v1, e.g. /v1/messages, /v1/responses or /v1/chat/completions, which is joined to the base.

Index

Constants

View Source
const (
	AnthropicEndpoint = "https://api.anthropic.com/v1"
	OpenAIEndpoint    = "https://api.openai.com/v1"
)

Preset endpoints.

View Source
const DefaultAnthropicVersion = "2023-06-01"

DefaultAnthropicVersion is sent on Anthropic requests that set none.

View Source
const DefaultMaxRequestBytes int64 = 32 << 20

DefaultMaxRequestBytes bounds proxied request bodies.

View Source
const ProbeTTL = 6 * time.Hour

ProbeTTL is how long a successful request probe is trusted. Probes are real (one-token) requests, so they are not repeated on every check.

Variables

This section is empty.

Functions

func APIForPath

func APIForPath(path string) string

APIForPath returns the API a proxied request path belongs to: one of the harnesses.API* constants, "models" for a model listing, or "" when the path is not a model API.

func New

New builds the adapter. cfg.Secret["api_key"] is required; cfg.Endpoint overrides the preset base URL; cfg.Model describes the endpoint; cfg.Extra["max_request_bytes"] overrides the body cap.

Types

type Adapter

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

Adapter implements connectors.Model.

func (*Adapter) Host

func (a *Adapter) Host() string

Host is the upstream host, recorded with each proxied request.

func (*Adapter) Proxy

func (a *Adapter) Proxy() http.Handler

Proxy returns the credential-injecting reverse proxy. The request path is the API path, e.g. /v1/messages.

func (*Adapter) Serves

func (a *Adapter) Serves(api string) bool

Serves reports whether the connection serves api.

func (*Adapter) Verify

func (a *Adapter) Verify(ctx context.Context) error

Verify checks the credential and the endpoint's claims (spec verify mode): request sends a minimal request for each API and model (results are trusted for ProbeTTL), models lists models, none checks nothing remote. A failure names the API and model.

Jump to

Keyboard shortcuts

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