pub struct KernelHttpGateway<C: KernelGatewayConfig> { /* private fields */ }Expand description
Generic kernel gateway: reqwest transport + the pure translation in
causa_protocol::translation composed with the shared error
mapping table and control-plane wiring from crate::gateway_transport.
Media: an optional host-injected MediaResolver turns the frame’s
fact-level references into inline payloads right before rendering —
batch and stream share one resolution pass. Without a resolver, every
reference degrades to its text placeholder.
Implementations§
Source§impl<C: KernelGatewayConfig> KernelHttpGateway<C>
impl<C: KernelGatewayConfig> KernelHttpGateway<C>
Sourcepub fn new(api_key: impl Into<String>) -> Self
pub fn new(api_key: impl Into<String>) -> Self
Build a gateway with the protocol’s default endpoint and configuration. Media resolution is absent until the host injects a resolver.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> Self
pub fn with_base_url(self, base_url: impl Into<String>) -> Self
Point at a non-default host (test doubles, gateways). C::PATH
is appended to the given base URL, which must carry its own version
segment: https://api.anthropic.com/v1, https://api.openai.com/v1,
or https://host/provider/v1 for a compatible provider. A base
without a version segment is used as given.
Sourcepub fn with_endpoint(self, endpoint: impl Into<String>) -> Self
pub fn with_endpoint(self, endpoint: impl Into<String>) -> Self
Full endpoint override (host + path).
Sourcepub fn with_http_client(self, http: Client) -> Self
pub fn with_http_client(self, http: Client) -> Self
Replace the HTTP client with one configured by the host.
The default client disables redirects and retries, and configures a
connect timeout and idle read timeout without a total timeout. A supplied
client’s transport policies remain host-owned: disable both for the same
single-request guarantee. Note that a supplied client configured with its
own .timeout(...) reintroduces a total request cap that cuts off long
streaming or generation turns; total duration belongs to the
CallControl deadline instead. Cancellation and deadlines remain
enforced independently of the supplied client’s timeout settings.
Sourcepub fn with_media_resolver(self, resolver: Arc<dyn MediaResolver>) -> Self
pub fn with_media_resolver(self, resolver: Arc<dyn MediaResolver>) -> Self
Inject the media resolver: the host’s asset table the gateway consults for every media reference in the frame.
Sourcepub fn with_max_inline_media_bytes(
self,
kind: MediaKind,
max_bytes: usize,
) -> Self
pub fn with_max_inline_media_bytes( self, kind: MediaKind, max_bytes: usize, ) -> Self
Override the inline media ceiling for one MediaKind, in decoded
bytes. Each kind defaults to 5 MiB.
The ceiling constrains inline payloads only (MediaSource::Inline);
remote URLs (MediaSource::Url) are neither limited nor fetched. An
inline payload over its kind’s ceiling renders as the placeholder, like
a resolver miss. The total size of a request is not checked; that is
the provider’s limit.
Sourcepub fn with_stream_limits(self, limits: StreamLimits) -> Self
pub fn with_stream_limits(self, limits: StreamLimits) -> Self
Override the pure decoder’s framing, total-input, output and item budgets. Invalid limits are rejected before sending a streaming request.
Source§impl KernelHttpGateway<AnthropicGatewayConfig>
impl KernelHttpGateway<AnthropicGatewayConfig>
Sourcepub fn with_anthropic_version(self, version: impl Into<String>) -> Self
pub fn with_anthropic_version(self, version: impl Into<String>) -> Self
Override the anthropic-version header (default 2023-06-01).
Sourcepub fn with_beta(self, value: impl Into<String>) -> Self
pub fn with_beta(self, value: impl Into<String>) -> Self
Append one extra anthropic-beta value for this gateway. Values are
sent as one comma-separated anthropic-beta header, in the order
listed, followed by the value an enabled option needs; nothing is
sent by default and no model table decides headers.
Sourcepub fn with_render_options(self, options: AnthropicRenderOptions) -> Self
pub fn with_render_options(self, options: AnthropicRenderOptions) -> Self
Replace every render option at once, including any set earlier with
the per-option setters (a later call wins either way). Wire
consequences follow from the options: native_tool_changes still adds
inline-tools-2026-09-15 to anthropic-beta. The value usually comes
from host configuration, as which servers and models support an option
is the host’s to decide.
Sourcepub fn with_native_tool_changes(self, native: bool) -> Self
pub fn with_native_tool_changes(self, native: bool) -> Self
Render tool changes in place (default false).
tools stays at the context’s first tool change and each later
change is sent at its position as tool_removal / tool_addition
blocks, so a changed tool listing keeps the cached prefix and earlier
thinking. The gateway adds the inline-tools-2026-09-15 beta value
it needs. Off, every request carries the current tools in tools.
Enable only for a server known to support it: a server without support
may reject the request, or ignore the change so the model never sees
the added tool.
Source§impl KernelHttpGateway<OpenAiChatGatewayConfig>
impl KernelHttpGateway<OpenAiChatGatewayConfig>
Sourcepub fn with_render_options(self, options: ChatRenderOptions) -> Self
pub fn with_render_options(self, options: ChatRenderOptions) -> Self
Replace every render option at once, including any set earlier with the per-option setters (a later call wins either way). Wire consequences follow from the options. The value usually comes from host configuration, as which servers and models support an option is the host’s to decide.
Sourcepub fn with_reasoning_content_replay(self, replay: bool) -> Self
pub fn with_reasoning_content_replay(self, replay: bool) -> Self
Replay sealed reasoning_content message-level items (default true).
DeepSeek requires reasoning_content back on every request that
carries tools; turning this off removes the key from the renderer’s
own sealed items and changes nothing else. The choice is per gateway
value, not per request: a host that needs both holds two gateways.
Sourcepub fn with_max_tokens_field(self, field: ChatMaxTokensField) -> Self
pub fn with_max_tokens_field(self, field: ChatMaxTokensField) -> Self
Choose the request field that carries the output limit (default
ChatMaxTokensField::MaxCompletionTokens).
Only the chosen field is sent. ChatMaxTokensField::MaxTokens is
for a server that reads only the older max_tokens; a server that
does not read the chosen field applies no limit and reports no error.
The choice is per gateway value, not per request.
Source§impl KernelHttpGateway<OpenAiResponsesGatewayConfig>
impl KernelHttpGateway<OpenAiResponsesGatewayConfig>
Sourcepub fn with_render_options(self, options: ResponsesRenderOptions) -> Self
pub fn with_render_options(self, options: ResponsesRenderOptions) -> Self
Replace every render option at once, including any set earlier with the per-option setters (a later call wins either way). Wire consequences follow from the options. The value usually comes from host configuration, as which servers and models support an option is the host’s to decide.
Sourcepub fn with_encrypted_reasoning(self, include: bool) -> Self
pub fn with_encrypted_reasoning(self, include: bool) -> Self
Send include: ["reasoning.encrypted_content"] (default true).
Without it a reasoning item cannot be meaningfully replayed under
store: false or zero data retention. The choice is per gateway value,
not per request: a host that needs both holds two gateways.
Sourcepub fn with_store(self, store: Option<bool>) -> Self
pub fn with_store(self, store: Option<bool>) -> Self
Render store; None omits the field (default Some(false), as Codex
and pi-ai send it). The host owns the data-retention choice. The
choice is per gateway value, not per request.
Sourcepub fn with_additional_tools(self, additional_tools: bool) -> Self
pub fn with_additional_tools(self, additional_tools: bool) -> Self
Send added tools as additional_tools input items (default false).
tools stays at the context’s first tool change and each later
addition is sent at its position, as Codex does, so the cached prefix
survives it. A context in which a later change removes a tool or
redefines one renders with the current tools in tools, as with this
off. Enable only for a server known to support it: a server without
support may reject the request, or ignore the change so the model never
sees the added tool.
Trait Implementations§
Source§impl<C: KernelGatewayConfig> Clone for KernelHttpGateway<C>
impl<C: KernelGatewayConfig> Clone for KernelHttpGateway<C>
Source§impl<C: KernelGatewayConfig> Debug for KernelHttpGateway<C>
impl<C: KernelGatewayConfig> Debug for KernelHttpGateway<C>
Source§impl<C: KernelGatewayConfig> ModelGateway for KernelHttpGateway<C>
impl<C: KernelGatewayConfig> ModelGateway for KernelHttpGateway<C>
Source§fn stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: &'life1 ModelRequest,
control: &'life2 CallControl,
) -> Pin<Box<dyn Future<Output = Result<ModelStream, ModelInvokeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: &'life1 ModelRequest,
control: &'life2 CallControl,
) -> Pin<Box<dyn Future<Output = Result<ModelStream, ModelInvokeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
StreamDelta::Done after invoke — providers that never
implemented streaming keep working through the same port; streaming
providers override to expose real token increments.Source§fn invoke<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: &'life1 ModelRequest,
control: &'life2 CallControl,
) -> Pin<Box<dyn Future<Output = Result<ModelOutput, ModelInvokeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn invoke<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
request: &'life1 ModelRequest,
control: &'life2 CallControl,
) -> Pin<Box<dyn Future<Output = Result<ModelOutput, ModelInvokeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
ModelOutput, or a classified ModelInvokeError.
Cancellation and the deadline arrive through control.