Expand description
Backend-independent messages and one-attempt streaming model drivers.
Construct a driver with new and GenerativeModelConfig, then pass a
complete conversation to GenerativeModel::generate. The library accepts
resolved settings and credentials; it does not read application config files.
§Streaming and policy
Every call performs one attempt. Consume GenerationEvent directly for
incremental output and failure metadata, feeding parts to MessageAccumulator.
Use GenerateOutput::from_generation when only the completed output is needed.
Dropping a stream cancels its request. Retry, tool execution, and persistence
belong to the caller; myco-agent supplies the model/tool loop and retry policy.
§History contract
Message::ToolResults must immediately follow its assistant’s tool calls,
with one result per call in the same order. Wire IDs are generated by the
drivers. Preserve these pairs when saving or slicing history.
See the inference guide
and the inference example for a complete streaming client. The example
requires an endpoint; ordinary library tests use local fixtures.
Structs§
- Anthropic
Backend Config - Anthropic Messages API settings (
BackendConfig::Anthropic). - Catalog
Model - One usable catalog entry: spec plus the backend (gateway + credentials) that serves it.
- Generate
Output - Generation
Failure - Generative
Model Config - Fully resolved driver inputs. Tool schemas advertise capabilities; the caller remains responsible for executing calls and validating their arguments.
- Message
Accumulator - Model
Catalog - Key → model catalog resolved from config.toml. Empty when the user has not configured any models.
- Model
Spec - A resolved model: everything the protocol drivers need, minus credentials
(those live in
BackendConfig). Built by the application configuration from the[models]/[gateways]catalog in config.toml — myco ships no built-in models. - OpenAI
Backend Config - Settings for either OpenAI dialect (
BackendConfig::OpenAIResponses/BackendConfig::OpenAICompletions). - Retry
Policy - Agent policy for retrying transient failures before any response parts arrive.
Resolved from
[gateways.NAME.retry]or[models.KEY.retry]. - Token
Usage - Token counts for one generate call.
cached_input_tokensis a subset ofinput_tokens. - Tool
Result - Tool
Spec - ToolUse
- A tool call in an assistant turn. Carries no id: a call is identified by
its position (message index + ordinal), and the
j-th entry of the next message’stool_use_resultsanswers it. Providers that need ids on the wire get minted ones from the driver. - Tool
UseDelta - Tool
UseStart
Enums§
- Backend
Config - Provider backend settings: gateway base URL, credential, per-request knobs.
- Content
- Content
Delta - Content
Start - Effort
- Reasoning / extended-thinking effort level sent to providers.
- Generate
Error - Generation
Event - One generation attempt emits parts, or ends with a failure.
- Message
- Message
Part - Model
Creation Error - Protocol
- Wire protocol a model is served over.
- Recovery
- What a caller can do about a failed turn.
- Thinking
Mode - How thinking/reasoning is requested for a model.
- Turn
EndReason
Constants§
- MAX_
REQUEST_ BYTES - Default ceiling on one serialized API request body: 30 MB (decimal).
Traits§
Functions§
- answer_
content - Clone only answer blocks (
Text/Image), dropping thinking. - new
- Construct a driver, rejecting a protocol/backend mismatch before any request. No network request is made until the returned model is asked to generate.