Skip to main content

Module models

Module models 

Source
Expand description

Model abstractions: the Model trait, its request and result types, stream events and what the SDK knows about models (ModelInfo).

Re-exports§

pub use anthropic::AnthropicBedrockConfig;
pub use anthropic::AnthropicClientConfig;
pub use anthropic::AnthropicModel;
pub use anthropic::AnthropicModelConfig;
pub use anthropic::AnthropicModelOptions;
pub use bedrock::BedrockModel;
pub use bedrock::BedrockModelConfig;
pub use bedrock::BedrockModelOptions;
pub use openai::BedrockMantleConfig;
pub use openai::OpenAIApi;
pub use openai::OpenAIClientConfig;
pub use openai::OpenAIModel;
pub use openai::OpenAIModelConfig;
pub use openai::OpenAIModelOptions;

Modules§

anthropic
The Anthropic Messages API provider, behind the anthropic feature.
bedrock
The Amazon Bedrock model provider, behind the bedrock feature (on by default).
openai
The OpenAI provider, behind the openai feature.
routing
Strategy-based model routing.
streaming
Model stream events, token usage and metrics.

Structs§

BaseModelConfig
Configuration every model provider supports (BaseModelConfig).
CacheConfig
Prompt caching configuration (CacheConfig). Providers consume only the fields they support.
CountTokensOptions
Options for Model::count_tokens (CountTokensOptions).
ModelCapabilities
What the model can do (ModelCapabilities). None is unknown.
ModelInfo
Everything the SDK knows about a model (ModelInfo). Read it from Model::model_info.
ModelLimits
Size limits of the model (ModelLimits). None is unknown.
ModelRequest
One request to a model: the conversation and its options.
Redaction
Redaction of the user’s input when a guardrail blocked it (Redaction).
StreamAggregatedResult
The final value of Model::stream_aggregated (StreamAggregatedResult).
SummarizeOptions
Options for Model::summarize (SummarizeOptions).
SummarizeResult
The result of Model::summarize (SummarizeResult).

Enums§

AggregatedEvent
An item of Model::stream_aggregated: a raw event, a completed block, or the final result.
CacheKey
The prompt-cache routing key for providers that route by key.
CacheSectionSetting
Whether a cache section is cached, and for how long.
CacheStrategy
Whether caching skips models that are not known to support it (CacheConfig.strategy).
DeferredToolLoading
How a model keeps deferred tool schemas out of its context until it loads them (DeferredToolLoading).
PromptCaching
How a model supports prompt caching (PromptCaching).

Traits§

Model
A model provider (Model).

Functions§

base_model_info
The default Model::model_info for a configuration, before any provider facts: the shared model info for the model id, temporary_messages off, deferred_tool_loading as Stubs unless the shared info says Unsupported, the context_window_limit and the model_info override. A provider that overrides Model::model_info starts from it (see ModelInfo::merge).
estimate_tokens
The default Model::count_tokens estimate: text length / 4 and JSON length / 2, in UTF-16 code units, with only the latest user message’s injected blocks.
summarize_client_side
The default Model::summarize: sends messages as a request that ends with one summarize instruction and returns the reply’s text as a SummaryBlock.

Type Aliases§

BoxStream
A pinned, boxed, Send stream, as returned by Model::stream.
CacheTtl
TTL of a cache entry (CacheTTL), such as "5m" or "1h". Providers validate it server-side.