Skip to main content

Module driver

Module driver 

Source
Expand description

Calls a model. A Model pairs a Wire (what to send and how to read the reply) with a Transport (how the payload travels). Its stream yields any operation’s events as a Streamed, and its call is that stream, finished: one decoder, one fold and one response constructor for both.

use rig_core::completion::CompletionRequest;
use rig_core::driver::Model;
use rig_core::providers::openai::{self, OpenAIConfig};

let model = OpenAIConfig::from_env()?.connect(http).responses(openai::GPT_5_2);
let response = model.call(CompletionRequest::new("Hello")).await?;

Structs§

DynModel
A model of one operation with its wire and transport erased. Clones share the model. Built with Model::erase or From<Model<W, T>>, so a consumer takes impl Into<DynModel<Op>> and accepts either.
Exchange
What the driver tells a transport about one send.
Local
A wire whose payload is the request and whose frames are the reply’s steps, for an operation whose events the runtime builds itself.
Model
An endpoint of one provider: a wire bound to a transport.
Opened
One reply a transport opened: its frames, and the facts the transport owns.
Opening
One reply, opened when first polled.

Enums§

Step
One step of a local runtime’s reply.

Constants§

STREAM_IDLE_TIMEOUT
How long a streamed reply may send no frame, from when it was sent to its first frame or between two, before it fails as ProviderError::Stalled: five minutes. Only a frame restarts it: any event the wire reads, a provider’s ping event included. Bytes that are no frame, such as an event stream’s comments, never do. A model that thinks at length is cut only if its provider sends no event for that long.

Traits§

Transport
Sends a wire’s payloads and delivers its replies’ frames.

Functions§

warn_unmodeled
Logs an unmodeled payload’s kind and serialized size, never its content. Callers must supply a structural kind label without sensitive data.