Skip to main content

Crate respan_gateway

Crate respan_gateway 

Source
Expand description

The respan-gateway application, as a library: its configuration (Config) and the HTTP application composed from it (App), for the respan-gateway binary and any host that embeds it.

use respan_gateway::{App, Config};
let app = App::new(Config::discover(None)?)?;
// Its providers' lists, which price and route the first calls.
app.listed().await;
let listener = tokio::net::TcpListener::bind(app.listen()).await?;
println!("{}", app.banner(listener.local_addr()?));
app.serve(listener, respan_gateway::shutdown_signal()).await?;

A custom gateway, with plugins of its own, builds its own respan_gateway_core::Gateway instead.

Structs§

App
A gateway built from a Config, and its HTTP application: the formats served, /healthz, /v1/models, the request log, and the web UI with its admin API.
Config
A gateway’s configuration, as gateway.toml writes it.
Error
A configuration that cannot be read or composed: what is wrong, and where.
McpConfig
One MCP server, as gateway.toml writes it under tools, in the fields MCP clients’ mcp.json use, so an entry copies across: a url (streamable HTTP) with its headers and auth, or a command (stdio) with its args, env and cwd.
NetworkConfig
[network].
OAuthConfig
auth = { oauth = { .. } } of a tool server: the gateway’s own client.
PluginsConfig
The compiled-in plugins. Each is configured under its own name, and the gateway registers them in a fixed order: the request log, routing, the MCP aggregate, video jobs, the tool loop, then the dispatch of routes. Video jobs are always on; a vendor’s quirks are in the formats it speaks, not plugins.
Price
A model’s price, in US dollars per million tokens, and per second of audio for a model billed by its length.
ProviderConfig
One provider: a vendor, explicit formats, or a vendor with some of its settings replaced.
Reloaded
What a reload took in.
RequestLogConfig
The request log: the history of finished requests.
RouteConfig
One route: the candidates a model name goes to, and how they are picked, retried and raced.
RouteTarget
A route’s candidate, alone or weighted.
RouteWhen
Which requests a route applies to.
RoutingConfig
Routing: which provider each request goes to.
Trusted
The mark of a request from the process that owns the gateway: the embedding library’s own reads of the admin API. It is a typed extension of the in-process request, set only by that code; no header, query or body can make one, so a request from the network never has it. require accepts it in place of a client key for reads: the admin API and the model lists.

Enums§

Auth
Commit
How far an attempt’s answer is read before it counts as a success, and nothing is retried after.
LogFormat
How log lines are written. off silences the request log alone: warnings are always written.
Pick
How a route orders its candidates for a request. Whichever it is, one that failed its last few calls just now goes last.
Proxy
A proxy setting: a URL, or none.
ProxyVendor
The vendor proxy relays to.
ReloadError
Why a reload did not happen. The gateway keeps serving as it was.
Source
Where a configuration came from.

Constants§

DEFAULT_FILE
The file read when none is named.
DEFAULT_LISTEN
Where the gateway listens unless told.
VERSION
This binary’s version, the workspace’s.

Functions§

execute
Runs the command line as the binary does: reads the nearest .env if there is one, then runs on a runtime of its own.
no_keys_message
What to do when there is no config file and no key in the environment.
run
Runs the respan-gateway command line on args (the program name first) and returns its exit status.
shutdown_signal
Resolves on Ctrl-C, or on SIGTERM where there is one.
starter_config
The starter config from the environment alone.