Documentation
¶
Overview ¶
Package v1 implements the OpenAI-compatible /v1/... API endpoints.
Incoming requests are:
- Authenticated via the Internal Token Service
- Validated against the token's rules (allowed models)
- Routed to the appropriate provider by the Router Service
- Translated back to OpenAI-compatible responses
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildStreamMetricEvent ¶ added in v0.4.0
func BuildStreamMetricEvent(start time.Time, model models.ModelId, providerID, tokenID string, duration time.Duration, streamErr error) models.MetricEvent
BuildStreamMetricEvent builds the shared MetricEvent for one streaming request. Streams hardcode 500 on failure: headers already went out with 200, so the mapped status never reaches the client. Non-streaming recordRouteMetric maps the status instead; the two semantics stay separate.
func MarshalOpenAIStreamError ¶ added in v0.4.0
MarshalOpenAIStreamError renders the OpenAI-shaped error envelope sent as an SSE data frame when a stream fails mid-flight. Callers own the write and flush so the Anthropic path (translatedWriter.emit) stays separate.
func WriteOpenAIStreamError ¶ added in v0.4.0
WriteOpenAIStreamError marshals the error envelope and emits it as an SSE data frame. It shares the exact write sequence of the OpenAI streaming paths; the dashboard path keeps its own guarded write on top of MarshalOpenAIStreamError.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler holds the dependencies for the v1 API.
type Params ¶ added in v0.1.2
type Params struct {
Tokens *token.GormService
RouterSvc *router.Service
MetricsSvc *metrics.Service
ProviderSvc *provider.GormService
ModelInfoSvc *modelinfo.GormService
VirtualSvc *virtual.GormService
Logger *slog.Logger
}
Params carries every dependency of the v1 Handler in one value, so adding a service touches one struct instead of every call site.