Expand description
§nenjo-providers
LLM provider trait, types, and implementations for the Nenjo agent platform.
This crate provides:
- The
ModelProvidertrait for LLM integrations - Message types:
ChatMessage,ChatRequest,ChatResponse,ToolCall - Provider implementations: Anthropic, OpenAI, Gemini, Ollama, OpenRouter, and OpenAI-compatible providers
- Reliability wrappers:
ReliableProvider(retry/fallback),RouterProvider(model routing)
Re-exports§
pub use native::EditImageRequest;pub use native::EditVideoRequest;pub use native::ExtendVideoRequest;pub use native::GenerateImageRequest;pub use native::GenerateSpeechRequest;pub use native::GenerateVideoRequest;pub use native::ImageToVideoRequest;pub use native::MediaInputAsset;pub use native::MediaOutputAsset;pub use native::MediaOutputFormat;pub use native::ModelNativeCapabilities;pub use native::NativeCapabilitiesProvider;pub use native::NativeExecutionMode;pub use native::NativeMediaJob;pub use native::NativeMediaJobStatus;pub use native::NativeMediaRequest;pub use native::NativeMediaResponse;pub use native::NativeModelToolId;pub use native::NativeOperation;pub use native::NativeToolSpec;pub use native::ProviderNativeCapabilities;pub use native::ProviderNativeModelToolSpec;pub use native::ReferenceToVideoRequest;pub use native::TranscribeAudioRequest;pub use traits::ChatMessage;pub use traits::ChatRequest;pub use traits::ChatResponse;pub use traits::ConversationMessage;pub use traits::ModelProvider;pub use traits::ProviderStreamEvent;pub use traits::ProviderToolTrace;pub use traits::TokenUsage;pub use traits::one_shot;pub use anthropic::AnthropicProvider;pub use compatible::AuthStyle;pub use compatible::OpenAiCompatibleProvider;pub use gemini::GeminiProvider;pub use ollama::OllamaProvider;pub use openai::OpenAiProvider;pub use openrouter::OpenRouterProvider;pub use reliable::ReliableProvider;pub use router::RouterProvider;pub use xai::XAI_DEFAULT_BASE_URL;pub use xai::XAiProvider;
Modules§
- anthropic
- Anthropic Claude provider. Authenticates via
x-api-keyheader. - compatible
- Generic OpenAI-compatible provider.
Most LLM APIs follow the same
/v1/chat/completionsformat. This module provides a single implementation that works for all of them. - gemini
- Google Gemini provider with support for:
- native
- Provider-native media and model capability contracts.
- ollama
- Local Ollama provider. No authentication required, configurable base URL
(defaults to
http://localhost:11434). - openai
- OpenAI provider. Authenticates via Bearer token.
- openrouter
- OpenRouter aggregator provider. Authenticates via Bearer token, routes to multiple upstream models with provider-order pinning.
- reliable
- Reliability wrapper providing exponential-backoff retries, provider fallback, API key rotation, and model failover.
- router
- Multi-model router that dispatches requests to different provider+model combinations based on hint-prefixed model names.
- traits
- xai
- xAI provider.
Structs§
- Tool
Call - A tool call requested by the LLM.
- Tool
Result Message - A tool result to feed back to the LLM.
- Tool
Spec - Full specification of a tool for LLM registration.
Enums§
- Tool
Category - Classifies a tool’s side-effect profile for filtering and model guidance.
Traits§
- Model
Provider Factory - Maps a model provider name (for example,
"openai"or"anthropic") to an LLM provider implementation. - Typed
Model Provider Factory - Typed variant of
ModelProviderFactoryusing a generic associated model provider type.
Functions§
- api_
error - Build a sanitized provider error from a failed HTTP response.
- sanitize_
api_ error - Sanitize API error text by scrubbing secrets and truncating length.
- sanitize_
tool_ name - Sanitize a tool function name to match the strict OpenAI pattern
^[a-zA-Z0-9_-]+$. - sanitize_
tool_ name_ lenient - Light sanitization for lenient providers (Ollama) while preserving dots used in MCP namespaced tool names.
- scrub_
secret_ patterns - Scrub known secret-like token prefixes from provider error strings.
- strip_
thinking - Strip
<think>…</think>blocks from model output.