Skip to main content

Crate a2a_llm

Crate a2a_llm 

Source
Expand description

Provider-neutral vocabulary for chat completions, plus the providers that speak it.

LlmProvider is the port: chat_completion and chat_completion_stream over LlmRequest / LlmResponse. openai covers OpenAI and every OpenAI-compatible endpoint (OpenRouter, vLLM, llama.cpp); gemini covers Google’s API. provider_from_env picks one from the environment.

The types are deliberately not tied to A2A. ToolCall and ToolDefinition are the tool-calling vocabulary shared with the MCP bridge, which is why they live in their own crate rather than inside an agent framework.

Re-exports§

pub use provider::LlmConfigError;
pub use provider::LlmSettings;
pub use provider::PROVIDER_ENV_VARS;
pub use provider::ReasoningPlan;
pub use provider::SUPPORTED_PROVIDERS;
pub use provider::SelectedLlm;
pub use provider::provider_from_env;
pub use provider::provider_from_settings;
pub use tool_call::PartialToolCall;
pub use tool_call::ToolCallAccumulator;

Modules§

gemini
openai
provider
Centralized LlmProvider selection.
tool_call
Incremental tool-call assembly for streaming LLM responses.

Structs§

ChatMessage
A single message in a chat conversation.
LlmRequest
A request to an LLM provider for chat completion.
LlmResponse
A response from an LLM provider.
TokenUsage
Tokens a provider reported for one request.
ToolCall
Represents a specific tool invocation requested by the LLM.
ToolDefinition
Defines a tool (function) available for the LLM to call.

Enums§

LlmError
Represents an error returned by an LLM provider.
LlmStreamEvent
An event emitted during a streaming LLM response.
MessageRole
The role of the message sender.
Reasoning
What to ask a reasoning-capable model to do with its thinking.
ReasoningEffort
How hard a reasoning model should think, when reasoning is requested.

Traits§

LlmProvider
Trait defining a generic LLM provider for standardizing AI integration across agents.