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.tomlwrites it. - Error
- A configuration that cannot be read or composed: what is wrong, and where.
- McpConfig
- One MCP server, as
gateway.tomlwrites it undertools, in the fields MCP clients’mcp.jsonuse, so an entry copies across: aurl(streamable HTTP) with itsheadersandauth, or acommand(stdio) with itsargs,envandcwd. - Network
Config [network].- OAuth
Config auth = { oauth = { .. } }of a tool server: the gateway’s own client.- Plugins
Config - 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.
- Provider
Config - One provider: a vendor, explicit formats, or a vendor with some of its settings replaced.
- Reloaded
- What a reload took in.
- Request
LogConfig - The request log: the history of finished requests.
- Route
Config - One route: the candidates a model name goes to, and how they are picked, retried and raced.
- Route
Target - A route’s candidate, alone or weighted.
- Route
When - Which requests a route applies to.
- Routing
Config - 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.
requireaccepts 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.
offsilences 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.
- Proxy
Vendor - The vendor
proxyrelays to. - Reload
Error - 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
.envif 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-gatewaycommand line onargs(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.