Documentation
¶
Overview ¶
Package gateway implements Surface 1 — the zero-code on-ramp. It exposes an OpenAI-compatible endpoint (/v1/chat/completions) and an Anthropic-compatible endpoint (/v1/messages). A user changes ONE env var (OPENAI_BASE_URL=http://localhost:7070/v1) and every call is intercepted: tagged with a run-id/step-id, governed by the deterministic budget enforcer, priced into the cost ledger, and forwarded to the real provider with the user's key.
Streaming (`stream:true`) is supported on both endpoints (OpenAI /v1/chat/completions and Anthropic /v1/messages): the budget is enforced before the stream opens, the provider's SSE is forwarded to the client verbatim while token usage is metered from it, and the run's context (time budget / kill switch / client disconnect) cuts a live stream. A provider whose backend doesn't implement streaming rejects a stream request with a clear error rather than silently degrading.
Index ¶
Constants ¶
const (
HeaderRunID = "X-RiskKernel-Run-Id"
)
Run-grouping request header and the response headers the gateway stamps onto every governed call. These names are part of the proxy's stable surface.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway holds the dependencies for the proxy handlers.
type Middleware ¶
type Middleware func(http.HandlerFunc) http.HandlerFunc
Middleware wraps a handler (e.g. with auth). Identity is a no-op default.