Expand description
Canonical AI wire types and per-protocol codecs for systemprompt.io, shared by the gateway and the agent provider clients.
The gateway speaks one provider-neutral model internally. Inbound adapters
parse a client wire request into a canonical::CanonicalRequest; outbound
adapters render that request to an upstream provider, parse the upstream
reply into a canonical::CanonicalResponse, and map upstream SSE bytes to
canonical::CanonicalEvents.
-
canonicalholds those provider-neutral request/response/event types. -
The per-protocol modules (
anthropic,openai_chat,openai_responses,gemini) hold the codec for one wire dialect: request build, response parse, stop-reason + usage mapping, SSE-to-event translation, and auth-header construction. -
protocolnames the wire dialect a provider speaks (WireProtocol),hostingthe platform in front of it (Hosting), andlimitsthe per-model token ceilings a codec clamps to (ModelLimits). -
schemaholds the per-provider JSON-Schema capability matrices and the tool-schema sanitiser the codecs apply before sending.
These types are defined ONCE here and re-exported by the gateway and the
agent provider clients so both layers share a single wire vocabulary. The
crate depends only on systemprompt-identifiers among the workspace
crates.
Copyright (c) systemprompt.io — Business Source License 1.1. See https://systemprompt.io for licensing details.
Re-exports§
pub use hosting::Hosting;pub use limits::ModelLimits;pub use protocol::WireProtocol;
Modules§
- anthropic
- Anthropic Messages wire codec.
- canonical
- Provider-neutral request, response, and streaming-event model.
- defect
- Detects an upstream buffered body that carries no turn at all.
- error
- Failures raised while reading a buffered upstream body or an upstream SSE stream.
- gemini
- Gemini
generateContent/streamGenerateContentwire codec. - hosting
- Where a provider’s models are hosted, as opposed to which wire they speak.
- inspect
- Inspection surface for outbound wire bodies.
- limits
- Token limits of one upstream model.
- openai_
chat OpenAIChat Completions wire codec.- openai_
responses OpenAIResponses wire codec.- protocol
- Wire-protocol family for an upstream AI provider.
- schema
- JSON-Schema capability matrices and sanitisation, shared by the gateway wire codecs and the agent-flow provider clients.
- sse
- Server-Sent Events framing shared by every provider SSE codec.
- upstream
- How one upstream is addressed: the pair of wire protocol and hosting.