Expand description
LLM wire types — request / response structures and the LlmProvider trait.
This module defines everything needed to communicate with an LLM backend: the provider trait, completion requests and responses, streaming events, model capabilities, and multimodal support (audio, images, video).
§Key types
| Type | Role |
|---|---|
LlmProvider | Trait implemented by each LLM backend (OpenRouter, Anthropic, Ollama…) |
CompletionRequest | Single completion request sent to a provider |
CompletionResponse | Non-streaming response wrapper |
StreamEvent | Incremental events from the provider’s stream |
CompletionStream | Alias for Pin<Box<dyn Stream<Item = Result<StreamEvent>>>> |
FinishReason | Why generation stopped (stop, length, tool_calls, content_filter) |
ToolDefinition | OpenAI-compatible JSON schema for tool calling |
ModelCapabilities | Feature flags (tool_calling, images, reasoning, audio…) |
TokenUsage | Token consumption reported by the provider |
Modality | Output modality: text, audio, or image |
TtsRequest, SttRequest, VideoGenRequest | Multimodal operation requests |
Structs§
- Audio
Output Config - Configuration for audio output in multimodal completions.
- Completion
Request - A single completion request sent to an LLM provider.
- Completion
Response - Non-streaming completion response wrapper.
- Frame
Image - An image used as a frame reference in video generation.
- Image
Edit Request - Parameters for editing one or more images.
- Image
GenConfig - Configuration for image generation requests.
- Image
GenRequest - Parameters for generating an image via a generative model.
- Image
Model Capabilities - Image capability metadata, when provided in a model catalog.
- Model
Capabilities - Feature flags describing what a model supports.
- Model
Info - Metadata about an available LLM model, including capabilities, pricing, and context window.
- Model
Pricing - Pricing information for a model, including input/output token costs and caching discounts.
- Reference
Pricing - Reference token rates from a separately identified source.
- SttRequest
- Parameters for a speech-to-text (transcription) request.
- Token
Usage - Token usage counts for a single completion request or turn.
- Tool
Definition - OpenAI-compatible JSON schema for a tool exposed to the LLM.
- TtsRequest
- Parameters for a text-to-speech request.
- Video
GenRequest - Parameters for generating a video from text prompts or image frames.
- Voice
- A voice available for text-to-speech generation.
Enums§
- Audio
Format - Output audio format for TTS responses.
- Finish
Reason - Why the LLM stopped generating (used in stream and non-stream responses).
- Image
Output Format - Image format requested from a provider.
- Modality
- Output modality requested in a completion.
- Model
Category - High-level category for filtering models by use-case.
- Reference
Pricing Source - Source of a model’s reference rates.
- Stream
Event - Events emitted incrementally by the provider’s stream.
Traits§
- LlmProvider
- Trait implemented by each LLM backend (OpenRouter, Anthropic, Ollama, etc.).
Functions§
- mime_
from_ extension - Infer MIME type from a file path’s extension.
Type Aliases§
- Completion
Stream - Type alias for a stream of completion events from an LLM provider.
- Provider
Registry - Shared registry mapping each
crate::model::Providerto its concrete instance.