Expand description
§systemprompt-ai
Provider-agnostic LLM integration for systemprompt.io.
systemprompt-ai is a domain layer crate that unifies Anthropic,
OpenAI, Gemini, and image-generation providers behind a single governed
pipeline with cost tracking, audit-trail persistence, and structured-output
validation.
It exposes:
AiService— top-level orchestration of generation, tool execution, structured output, planning, and Google-Search-grounded responses.ImageService— image generation and persistence.ImageStorage/StorageConfig— local file-system blob storage for generated images.- The
AiExtensionentrypoint that wires the crate into thesystemprompt-extensionframework. - Repository types (
AiRequestRepository,AiQuotaBucketRepository, …) for persisting request audit rows, quota buckets, gateway policies, and safety findings.
§Error model
All public service signatures return error::Result<T> (an alias for
Result<T, AiError>). AiError composes:
AiInferenceErrorfor the provider-trait seam- the canonical
RepositoryErrorfor persistence - common transport errors (
reqwest::Error,serde_json::Error,std::io::Error,regex::Error) and typed storage / stream causes - structured variants for conditions the crate itself detects (an unconfigured or disabled provider, an unsupported capability, a rejected AI policy), each carrying the values that caused it
The cross-domain AiProvider seam
returns AiInferenceResult
from services::core::ai_service.
§Feature flags
This crate has no Cargo features — all functionality is always compiled.
[package.metadata.docs.rs] sets all-features = true for parity with
sibling crates that do.
Copyright (c) systemprompt.io — Business Source License 1.1. See https://systemprompt.io for licensing details.
Re-exports§
pub use services::core::AiService;pub use services::core::AiServiceProviders;pub use services::core::ImageService;pub use services::core::ImageServiceParts;pub use services::storage::ImageStorage;pub use services::storage::StorageConfig;pub use services::storage::StorageConfigError;pub use services::tools::NoopToolProvider;pub use models::image_generation::AspectRatio;pub use models::image_generation::GeneratedImageRecord;pub use models::image_generation::ImageGenerationRequest;pub use models::image_generation::ImageGenerationResponse;pub use models::image_generation::ImageResolution;pub use models::image_generation::ReferenceImage;pub use services::providers::GeminiImageProvider;pub use services::providers::ImageProvider;pub use services::providers::ImageProviderCapabilities;pub use repository::AiGatewayPolicyRepository;pub use repository::AiQuotaBucketRepository;pub use repository::AiRequestPayloadRepository;pub use repository::AiRequestRepository;pub use repository::AiSafetyFindingRepository;pub use repository::GatewayPolicyRow;pub use repository::IncrementParams;pub use repository::InsertSafetyFinding;pub use repository::QuotaBucketDelta;pub use repository::QuotaBucketState;pub use repository::SafetyFindingRollupRow;pub use repository::UpsertPayloadParams;pub use services::upstream::UpstreamCall;pub use services::upstream::UpstreamTarget;pub use services::upstream::UpstreamTargetError;
Modules§
- error
- Typed error hierarchy for the
systemprompt-aicrate. - models
- Domain data types for the AI crate.
- repository
- Repository layer for AI domain persistence.
- services
- Service orchestration layer for the AI domain crate.
Structs§
- AiConfig
- AiExtension
- AiMessage
- AiRequest
- AiRequest
Builder - AiResponse
- Call
Tool Result - The result of a tool call operation.
- Generate
Response Params - Google
Search Params - McpTool
- Model
Config - Model
Preferences - Provider
Config - Sampling
Params - Search
Grounded Response - Structured
Output Options - Tool
Call - Upstream
Dialect