Skip to main content

Crate crabllm_core

Crate crabllm_core 

Source

Modules§

ir
json
JSON ser/de surface — to_vec / from_slice / to_string / from_str. With the sonic feature these route to SIMD-accelerated sonic-rs; without it, to serde_json.

Structs§

AnthropicMessage
AnthropicRequest
AnthropicResponse
AnthropicTool
AnthropicUsage
Anthropic wire-format usage. Field semantics follow Anthropic convention: input_tokens is only the uncached new portion; the three input fields are additive components of the total prompt. Convert to canonical Usage for any internal billing or metering use.
ApiError
OpenAI-compatible error response returned to clients.
ApiErrorBody
AudioSpeechRequest
ChatCompletionChunk
ChatCompletionRequest
ChatCompletionResponse
Choice
ChunkChoice
CompletionTokensDetails
Delta
Embedding
EmbeddingRequest
EmbeddingResponse
EmbeddingUsage
ExtensionError
Error returned by Extension::on_request to short-circuit the pipeline. Converted to an HTTP response in the handler.
FunctionCall
FunctionCallDelta
FunctionDef
GatewayConfig
Top-level gateway configuration, loaded from TOML.
GeminiCandidate
GeminiContent
GeminiFunctionCall
GeminiFunctionDecl
GeminiFunctionResponse
GeminiPart
GeminiRequest
GeminiResponse
GeminiToolDef
GeminiUsage
Gemini wire-format usage. Field semantics follow Google’s convention: prompt_token_count is the total prompt size (includes cached portion); cached_content_token_count is the cached subset. Convert to canonical Usage for any internal billing or metering use.
GenerationConfig
ImageRequest
KeyConfig
Virtual API key for client authentication.
KeyRateLimit
Per-key rate limit override. When set on a key, these values take precedence over the global [extensions.rate_limit] config.
Message
MessageDeltaPayload
Model
ModelInfo
Per-model metadata: context window and token pricing.
ModelList
MultipartField
A buffered multipart form field. Carries name, filename, content type, and bytes across the provider trait boundary without depending on any HTTP client crate.
OpenAiUsage
OpenAI wire-format usage. Field semantics follow OpenAI/DeepSeek-openai convention: prompt_tokens is the total prompt including cache, prompt_cache_hit_tokens is a subset. Convert to canonical Usage for any internal billing or metering use.
PricingConfig
Per-model token pricing. One rate per usage axis. Secondary rates are Option<f64> so “absent” means fall back to the coarser bucket rather than free — see crate::ModelInfo::cost for the fallback chain.
ProviderConfig
Configuration for a single LLM provider.
RequestContext
Per-request metadata passed to extension hooks.
Retrying
A Provider wrapper that retries transient failures with exponential backoff and full jitter, and bounds each attempt with a per-call timeout.
StorageConfig
Storage backend configuration.
ThinkingConfig
Tool
ToolCall
ToolCallDelta
Usage
Canonical token usage. Axes are disjoint — billing computes cost as a sum over (axis, rate) pairs without any subtraction or clamping.

Enums§

AnthropicContent
Message content: either a plain string or an array of content blocks.
AnthropicStreamEvent
AnthropicSystem
System prompt: either a plain string or an array of content blocks.
BlockDelta
ContentBlock
A content block within a message.
EmbeddingInput
Error
Shared error type for the crabllm workspace.
FinishReason
GeminiFinishReason
GeminiRole
ProviderKind
Which provider implementation to use. Known variants map to named dispatch paths. A self-defined name deserializes to Custom, which dispatches as OpenAI-compatible and requires base_url at validation.
Role
Stop
ToolChoice
Controls which tool the model should call.
ToolResultContent
Tool result content: either a plain string or nested content blocks.
ToolType

Constants§

DEFAULT_MAX_TOKENS
PREFIX_LEN
Fixed-length prefix size in bytes for storage keys.

Traits§

AnthropicMessages
Operations on a wire-level message list. Lives as a trait so call sites read as messages.coalesce_tool_results() rather than as free functions taking &mut Vec<AnthropicMessage>.
Extension
Trait for request pipeline extensions (usage tracking, logging, rate limiting, etc.).
Provider
The dispatch surface every provider implementation satisfies.
Storage
Generic async key-value storage backend for extensions.

Functions§

storage_key
Build a full storage key from a fixed-length prefix and a suffix.

Type Aliases§

AnthropicContentBlock
BoxFuture
A pinned, boxed, Send future. Used for dyn-compatible async trait methods.
BoxStream
A boxed, Send, dynamically-typed stream — used by Provider so the trait can return a uniform stream type without each implementor leaking its concrete combinator chain through an associated type.
ByteStream
Raw byte stream for SSE passthrough.
KvPairs
Key-value pairs returned by Storage::list.
Prefix
A fixed-length prefix that namespaces storage keys per extension.