Skip to main content

Module upstream

Module upstream 

Source
Expand description

Forwarding to the upstream Anthropic-compatible provider.

Observe mode is a transparent proxy: the request body and BYOK auth headers go upstream byte-for-byte, and the response comes back byte-for-byte. Firstpass never inspects, injects, or logs the API key.

Constants§

OPENAI_CHAT_PATH
The OpenAI-compatible inbound paths this proxy relays for.
OPENAI_RESPONSES_PATH
The Responses API path. A Responses-shaped body relayed to OPENAI_CHAT_PATH is rejected by the upstream, so the passthrough has to preserve which endpoint the client actually called.

Functions§

forward_anthropic
Forward one POST /v1/messages request and return its response buffered (full body). Used for non-streaming requests, where the assembled body also feeds the audit trace.
forward_anthropic_streaming
Forward one POST /v1/messages request and return the raw response for streaming relay (stream: true) — the caller pipes response.bytes_stream() to the client without buffering, preserving SSE chunk-by-chunk and keeping time-to-first-byte low.
forward_openai_path
Forward one OpenAI-compatible request to an explicit upstream path and return its response buffered. Observe-mode passthrough — a byte-identical relay.
forward_openai_streaming_path
Forward one OpenAI-compatible request to an explicit upstream path and return the raw response for streaming relay.