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 ¶
const ( AnthropicEndpoint = "https://api.anthropic.com/v1" OpenAIEndpoint = "https://api.openai.com/v1" )
Preset endpoints.
const DefaultAnthropicVersion = "2023-06-01"
DefaultAnthropicVersion is sent on Anthropic requests that set none.
const DefaultMaxRequestBytes int64 = 32 << 20
DefaultMaxRequestBytes bounds proxied request bodies.
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 ¶
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 ¶
func New(cfg connectors.Config) (connectors.Model, error)
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) Proxy ¶
Proxy returns the credential-injecting reverse proxy. The request path is the API path, e.g. /v1/messages.