Documentation
¶
Index ¶
- Constants
- func DownstreamWebsocket(ctx context.Context) bool
- func ResponseFormatOrSource(opts Options) sdktranslator.Format
- func WithDownstreamWebsocket(ctx context.Context) context.Context
- type Options
- type Request
- type RequestAfterAuthInterceptRequest
- type RequestAfterAuthInterceptResponse
- type RequestAfterAuthInterceptor
- type Response
- type StatusError
- type StreamChunk
- type StreamResult
Constants ¶
const ( // PinnedAuthMetadataKey locks execution to a specific auth ID. PinnedAuthMetadataKey = "pinned_auth_id" // SelectedAuthMetadataKey stores the auth ID selected by the scheduler. SelectedAuthMetadataKey = "selected_auth_id" // SelectedAuthCallbackMetadataKey carries an optional callback invoked with the selected auth ID. SelectedAuthCallbackMetadataKey = "selected_auth_callback" // ExecutionSessionMetadataKey identifies a long-lived downstream execution session. ExecutionSessionMetadataKey = "execution_session_id" )
const AuthSelectionModelMetadataKey = "auth_selection_model"
AuthSelectionModelMetadataKey overrides the model used only for auth selection.
const DisallowFreeAuthMetadataKey = "disallow_free_auth"
DisallowFreeAuthMetadataKey instructs auth selection to skip known free-tier credentials.
const ReasoningEffortMetadataKey = "reasoning_effort"
ReasoningEffortMetadataKey stores the client-requested reasoning effort for usage logs.
const RequestPathMetadataKey = "request_path"
RequestPathMetadataKey stores the inbound HTTP request path (e.g. "/v1/images/generations") in Options.Metadata. It is optional and may be absent for non-HTTP executions.
const RequestedModelMetadataKey = "requested_model"
RequestedModelMetadataKey stores the client-requested model name in Options.Metadata.
const ServiceTierMetadataKey = "service_tier"
ServiceTierMetadataKey stores the client-requested service tier for usage logs.
Variables ¶
This section is empty.
Functions ¶
func DownstreamWebsocket ¶
DownstreamWebsocket reports whether the current request originates from a downstream websocket connection.
func ResponseFormatOrSource ¶ added in v7.1.67
func ResponseFormatOrSource(opts Options) sdktranslator.Format
ResponseFormatOrSource returns the response target format for an execution.
Types ¶
type Options ¶
type Options struct {
// Stream toggles streaming mode.
Stream bool
// Alt carries optional alternate format hint (e.g. SSE JSON key).
Alt string
// Headers are forwarded to the provider request builder.
Headers http.Header
// Query contains optional query string parameters.
Query url.Values
// OriginalRequest preserves the inbound request bytes prior to translation.
OriginalRequest []byte
// SourceFormat identifies the inbound schema.
SourceFormat sdktranslator.Format
// ResponseFormat identifies the downstream response schema.
// Empty means responses should use SourceFormat for backward compatibility.
ResponseFormat sdktranslator.Format
// Metadata carries extra execution hints shared across selection and executors.
Metadata map[string]any
// RequestAfterAuthInterceptor runs after credential selection and before executor translation.
RequestAfterAuthInterceptor RequestAfterAuthInterceptor
}
Options controls execution behavior for both streaming and non-streaming calls.
type Request ¶
type Request struct {
// Model is the upstream model identifier after translation.
Model string
// Payload is the provider specific JSON payload.
Payload []byte
// Format represents the provider payload schema.
Format sdktranslator.Format
// Metadata carries optional provider specific execution hints.
Metadata map[string]any
}
Request encapsulates the translated payload that will be sent to a provider executor.
type RequestAfterAuthInterceptRequest ¶ added in v7.1.62
type RequestAfterAuthInterceptRequest struct {
// SourceFormat is the original client protocol format.
SourceFormat sdktranslator.Format
// ToFormat is the selected upstream protocol format.
ToFormat sdktranslator.Format
// Model is the selected upstream model for this attempt.
Model string
// RequestedModel is the client-requested model before alias/model-pool rewriting.
RequestedModel string
// Stream reports whether the request expects streaming output.
Stream bool
// Headers contains the current upstream request headers.
Headers http.Header
// Body contains the current request payload.
Body []byte
// Metadata is a best-effort cloned context snapshot. Treat it as read-only and JSON-like.
Metadata map[string]any
}
RequestAfterAuthInterceptRequest describes a selected-auth request before executor translation.
type RequestAfterAuthInterceptResponse ¶ added in v7.1.62
type RequestAfterAuthInterceptResponse struct {
// Headers replaces matching current request headers and preserves headers not mentioned here.
Headers http.Header
// Body replaces the current request body only when non-empty.
Body []byte
// ClearHeaders explicitly removes current request headers before Headers is applied.
ClearHeaders []string
}
RequestAfterAuthInterceptResponse returns selected-auth request modifications.
type RequestAfterAuthInterceptor ¶ added in v7.1.62
type RequestAfterAuthInterceptor func(context.Context, RequestAfterAuthInterceptRequest) RequestAfterAuthInterceptResponse
RequestAfterAuthInterceptor rewrites a request after credential selection and before executor translation.
type Response ¶
type Response struct {
// Payload is the provider response in the executor format.
Payload []byte
// Metadata exposes optional structured data for translators.
Metadata map[string]any
// Headers carries upstream HTTP response headers for passthrough to clients.
Headers http.Header
}
Response wraps either a full provider response or metadata for streaming flows.
type StatusError ¶
StatusError represents an error that carries an HTTP-like status code. Provider executors should implement this when possible to enable better auth state updates on failures (e.g., 401/402/429).
type StreamChunk ¶
type StreamChunk struct {
// Payload is the raw provider chunk payload.
Payload []byte
// Err reports any terminal error encountered while producing chunks.
Err error
}
StreamChunk represents a single streaming payload unit emitted by provider executors.
type StreamResult ¶
type StreamResult struct {
// Headers carries upstream HTTP response headers from the initial connection.
Headers http.Header
// Chunks is the channel of streaming payload units.
Chunks <-chan StreamChunk
}
StreamResult wraps the streaming response, providing both the chunk channel and the upstream HTTP response headers captured before streaming begins.