Expand description
Calling a model.
A completion is an effect like any other — journaled once, replayed from the record, untrusted on the way back. What is different is the meter.
§A failed completion is not a free one
Every other outward call this crate makes either happens or does not. A model call has a third state: it ran, generated four hundred tokens, and then the stream died. The provider will bill those tokens. The answer is unusable.
Two consequences, and both are easy to get backwards.
The spend must be reported anyway. EffectError::Metered carries what
was consumed, and the runtime bills it on the failure path. Without that, the
token and cost ceilings — the ones that exist to bound exactly this — count
zero while a retry loop against a flaky provider spends real money.
A died-mid-stream call is Disposition::Landed, not InDoubt. The
usual reasoning about reaching the peer is inverted here: we know perfectly
well that it reached the provider, because we watched it generate. What we
lack is the answer, and repeating the call buys a second bill for the same
question. InDoubt would invite Recovery to resolve an outcome that is
not in doubt at all.
§Determinism
A model is the least deterministic thing a run touches, which is exactly why the completion is journaled: replay reads the recorded answer rather than asking again. The prompt is part of the effect key, so a changed prompt is a changed effect and shows up as divergence rather than as a quietly different run.
Modules§
- anthropic
- A
ModelProviderfor the Anthropic Messages API. - bedrock
- Amazon Bedrock Runtime through the provider-neutral Converse API.
- chat_
completions - A
ModelProviderfor theOpenAI-compatible Chat Completions wire. - embeddings
- The embeddings wire, beside the drivers it shares a transport with. Embedding drivers, for the seam semantic retrieval needs.
- gemini
- A
ModelProviderfor the Google Gemini Developer API. - openai
- A
ModelProviderfor theOpenAIResponses API.
Structs§
- Completion
- What came back.
- Model
Call - One completion.
- ModelId
- Which model, from which provider.
- Model
Role - One model role, as a declaration resolves it: which model, and the ceilings the reviewer put beside it.
- Provider
Continuation - Opaque, self-contained provider state for one continuation turn.
- Request
- One request to a provider.
- Tool
Call - A tool the model asked to call.
- Tool
Declaration - A tool the model may ask for, as the request declares it.
- Tool
Exchange - A tool the model asked for, and what came back.
- Usage
- What a completion cost.
Enums§
- Model
Error - Why a completion failed.
- Model
Stream Event - A live, non-durable model-stream event.
- Reasoning
Effort - Provider-neutral reasoning depth.
- Schema
Mode - How a driver should obtain a schema-conforming answer.
Traits§
- Model
Provider - Talks to a provider.
- Model
Stream Observer - Receives live model progress while one terminal completion remains canonical.