liter_llm library

Classes

AssistantContent
AssistantMessage
Assistant's response to a user message.
AssistantPart
AudioContent
Audio content part for speech-capable models.
AuthConfig
Auth configuration block.
AuthHeaderFormat
BatchListQuery
Query parameters for listing batches.
BatchListResponse
Response from listing batches.
BatchObject
A batch job object.
BatchRequestCounts
Request processing counts for a batch.
BudgetConfig
Configuration for budget enforcement.
CacheBackend
CacheConfig
Configuration for the response cache.
ChatCompletionChunk
A streamed chunk of a chat completion response.
ChatCompletionRequest
Chat completion request (compatible with OpenAI and similar APIs).
ChatCompletionResponse
Chat completion response from the API.
ChatCompletionTool
A tool the model can invoke (currently, all tools are functions).
Choice
A single completion choice.
ContentPart
CreateBatchRequest
Request to create a batch job.
CreateFileRequest
Request to upload a file.
CreateImageRequest
Request to create images from a text prompt.
CreateResponseRequest
Request to create a structured response.
CreateSpeechRequest
Request to generate speech audio from text.
CreateTranscriptionRequest
Request to transcribe audio into text.
CustomProviderConfig
Configuration for registering a custom LLM provider at runtime.
DecodedDataUrl
Result of decoding a data: URL — MIME type and the decoded byte payload.
DefaultClient
DeleteResponse
Response from a delete operation.
DeveloperMessage
Developer message (system-like message for Claude models).
DocumentContent
PDF/document content part for vision-capable models.
EmbeddingInput
EmbeddingObject
A single embedding vector.
EmbeddingRequest
Embedding request.
EmbeddingResponse
Embedding response.
FileListQuery
Query parameters for listing files.
FileListResponse
Response from listing files.
FileObject
An uploaded file object.
FunctionCall
Function call details.
FunctionDefinition
Function definition exposed to the model.
FunctionMessage
Deprecated legacy function-role message body.
Image
A single generated image, returned as either a URL or base64 data.
ImagesResponse
Response containing generated images.
ImageUrl
An image URL reference with optional detail level for processing.
JsonSchemaFormat
JSON Schema specification for constrained output.
LiterLlmBridge
LiterLlmError
Message
ModelObject
A model available from the API.
ModelsListResponse
Response listing available models.
ModerationCategories
Boolean flags for each moderation category.
ModerationCategoryScores
Confidence scores for each moderation category.
ModerationInput
ModerationRequest
Request to classify content for policy violations.
ModerationResponse
Response from the moderation endpoint.
ModerationResult
A single moderation classification result.
OcrDocument
OcrImage
An image extracted from an OCR page.
OcrPage
A single page of OCR output.
OcrRequest
An OCR request.
OcrResponse
An OCR response.
PageDimensions
Page dimensions in pixels.
PromptTokensDetails
Breakdown of tokens used in the prompt portion of a request.
ProviderCapabilities
Static capability flags for a provider.
ProviderConfig
Static configuration for a single provider entry in providers.json.
RateLimitConfig
Configuration for per-model rate limits.
RerankDocument
RerankRequest
Request to rerank documents by relevance to a query.
RerankResponse
Response from the rerank endpoint.
RerankResult
A single reranked document with its relevance score.
RerankResultDocument
The text content of a reranked document, returned when return_documents is true.
ResponseFormat
ResponseObject
Response from a structured response request.
ResponseOutputItem
A single output item from the response.
ResponseTool
A tool available for the response request.
ResponseUsage
Token usage for a response.
SearchRequest
A search request.
SearchResponse
A search response.
SearchResult
An individual search result.
SpecificFunction
Name of the specific function to invoke.
SpecificToolChoice
Directive to call a specific tool.
StopSequence
StreamChoice
A streaming choice with incremental delta.
StreamDelta
Incremental delta in a stream chunk.
StreamFunctionCall
Partial function call details in a stream.
StreamOptions
Options for streaming responses.
StreamToolCall
A streaming tool call being built incrementally.
SystemMessage
System message guiding model behavior for the entire conversation.
ToolCall
A tool call the model wants to execute.
ToolChoice
ToolMessage
Tool execution result returned to the model.
TranscriptionResponse
Response from a transcription request.
TranscriptionSegment
A segment of transcribed audio with timing information.
Usage
Token-usage accounting returned by the provider on each completion / embedding call.
UserContent
UserMessage
User message in the conversation.
WaitForBatchConfig
Configuration for polling a batch until terminal status.

Enums

AuthType
Auth scheme used by a provider.
BatchStatus
Status of a batch job.
CircuitState
Observable state of a circuit breaker.
EmbeddingFormat
The format in which the embedding vectors are returned.
Enforcement
How budget limits are enforced.
FilePurpose
Purpose of an uploaded file.
FinishReason
Why a choice stopped generating tokens.
HealthStatus
The result of a single health probe.
ImageDetail
Image detail level controlling token cost and processing.
Modality
Output modality requested from the model.
ReasoningEffort
Controls how much reasoning effort the model should use.
StreamFormat
The streaming wire format a provider uses for its response stream.
ToolChoiceMode
Tool choice mode.
ToolType
The type discriminator for tool/tool-call objects.

Extensions

AssistantContentPatterns on AssistantContent
Adds pattern-matching-related methods to AssistantContent.
AssistantContentTextExt on AssistantContent
AssistantPartPatterns on AssistantPart
Adds pattern-matching-related methods to AssistantPart.
AuthHeaderFormatPatterns on AuthHeaderFormat
Adds pattern-matching-related methods to AuthHeaderFormat.
CacheBackendPatterns on CacheBackend
Adds pattern-matching-related methods to CacheBackend.
ContentPartPatterns on ContentPart
Adds pattern-matching-related methods to ContentPart.
EmbeddingInputPatterns on EmbeddingInput
Adds pattern-matching-related methods to EmbeddingInput.
LiterLlmErrorPatterns on LiterLlmError
Adds pattern-matching-related methods to LiterLlmError.
MessagePatterns on Message
Adds pattern-matching-related methods to Message.
ModerationInputPatterns on ModerationInput
Adds pattern-matching-related methods to ModerationInput.
OcrDocumentPatterns on OcrDocument
Adds pattern-matching-related methods to OcrDocument.
RerankDocumentPatterns on RerankDocument
Adds pattern-matching-related methods to RerankDocument.
ResponseFormatPatterns on ResponseFormat
Adds pattern-matching-related methods to ResponseFormat.
StopSequencePatterns on StopSequence
Adds pattern-matching-related methods to StopSequence.
ToolChoicePatterns on ToolChoice
Adds pattern-matching-related methods to ToolChoice.
UserContentPatterns on UserContent
Adds pattern-matching-related methods to UserContent.

Functions

allProviders() Future<List<ProviderConfig>>
Return all provider configs from the registry.
capabilities({required String providerName}) Future<ProviderCapabilities>
Return the capability flags for a named provider.
checkBound({required String context, required PlatformInt64 currentLen, required PlatformInt64 incoming, required PlatformInt64 limit}) Future<void>
Assert that current_len + incoming does not exceed limit.
clear() Future<void>
Remove all guardrails from the global registry.
completionCost({required String model, required PlatformInt64 promptTokens, required PlatformInt64 completionTokens}) Future<double?>
Calculate the estimated cost of a completion given a model name and token counts.
completionCostWithCache({required String model, required PlatformInt64 promptTokens, required PlatformInt64 cachedTokens, required PlatformInt64 completionTokens}) Future<double?>
Calculate the estimated cost of a completion, accounting for cached (cache-hit) prompt tokens billed at the provider's discounted rate.
complexProviderNames() Future<List<String>>
Return the set of complex provider names.
countRequestTokens({required String model, required ChatCompletionRequest req}) Future<PlatformInt64>
Count tokens for a full ChatCompletionRequest.
countTokens({required String model, required String text}) Future<PlatformInt64>
Count tokens in a text string using the tokenizer for the given model.
createAssistantMessageFromJson({required String json}) Future<AssistantMessage>
createAudioContentFromJson({required String json}) Future<AudioContent>
createAuthConfigFromJson({required String json}) Future<AuthConfig>
createBatchListQueryFromJson({required String json}) Future<BatchListQuery>
createBatchListResponseFromJson({required String json}) Future<BatchListResponse>
createBatchObjectFromJson({required String json}) Future<BatchObject>
createBatchRequestCountsFromJson({required String json}) Future<BatchRequestCounts>
createBudgetConfigFromJson({required String json}) Future<BudgetConfig>
createCacheConfigFromJson({required String json}) Future<CacheConfig>
createChatCompletionChunkFromJson({required String json}) Future<ChatCompletionChunk>
createChatCompletionRequestFromJson({required String json}) Future<ChatCompletionRequest>
createChatCompletionResponseFromJson({required String json}) Future<ChatCompletionResponse>
createChatCompletionToolFromJson({required String json}) Future<ChatCompletionTool>
createChoiceFromJson({required String json}) Future<Choice>
createClient({required String apiKey, String? baseUrl, PlatformInt64? timeoutSecs, PlatformInt64? maxRetries, String? modelHint}) Future<DefaultClient>
Create a new LLM client with simple scalar configuration.
createClientFromJson({required String json}) Future<DefaultClient>
Create a new LLM client from a JSON string.
createCreateBatchRequestFromJson({required String json}) Future<CreateBatchRequest>
createCreateFileRequestFromJson({required String json}) Future<CreateFileRequest>
createCreateImageRequestFromJson({required String json}) Future<CreateImageRequest>
createCreateResponseRequestFromJson({required String json}) Future<CreateResponseRequest>
createCreateSpeechRequestFromJson({required String json}) Future<CreateSpeechRequest>
createCreateTranscriptionRequestFromJson({required String json}) Future<CreateTranscriptionRequest>
createCustomProviderConfigFromJson({required String json}) Future<CustomProviderConfig>
createDecodedDataUrlFromJson({required String json}) Future<DecodedDataUrl>
createDeleteResponseFromJson({required String json}) Future<DeleteResponse>
createDeveloperMessageFromJson({required String json}) Future<DeveloperMessage>
createDocumentContentFromJson({required String json}) Future<DocumentContent>
createEmbeddingObjectFromJson({required String json}) Future<EmbeddingObject>
createEmbeddingRequestFromJson({required String json}) Future<EmbeddingRequest>
createEmbeddingResponseFromJson({required String json}) Future<EmbeddingResponse>
createFileListQueryFromJson({required String json}) Future<FileListQuery>
createFileListResponseFromJson({required String json}) Future<FileListResponse>
createFileObjectFromJson({required String json}) Future<FileObject>
createFunctionCallFromJson({required String json}) Future<FunctionCall>
createFunctionDefinitionFromJson({required String json}) Future<FunctionDefinition>
createFunctionMessageFromJson({required String json}) Future<FunctionMessage>
createImageFromJson({required String json}) Future<Image>
createImagesResponseFromJson({required String json}) Future<ImagesResponse>
createImageUrlFromJson({required String json}) Future<ImageUrl>
createJsonSchemaFormatFromJson({required String json}) Future<JsonSchemaFormat>
createModelObjectFromJson({required String json}) Future<ModelObject>
createModelsListResponseFromJson({required String json}) Future<ModelsListResponse>
createModerationCategoriesFromJson({required String json}) Future<ModerationCategories>
createModerationCategoryScoresFromJson({required String json}) Future<ModerationCategoryScores>
createModerationRequestFromJson({required String json}) Future<ModerationRequest>
createModerationResponseFromJson({required String json}) Future<ModerationResponse>
createModerationResultFromJson({required String json}) Future<ModerationResult>
createOcrImageFromJson({required String json}) Future<OcrImage>
createOcrPageFromJson({required String json}) Future<OcrPage>
createOcrRequestFromJson({required String json}) Future<OcrRequest>
createOcrResponseFromJson({required String json}) Future<OcrResponse>
createPageDimensionsFromJson({required String json}) Future<PageDimensions>
createPromptTokensDetailsFromJson({required String json}) Future<PromptTokensDetails>
createProviderCapabilitiesFromJson({required String json}) Future<ProviderCapabilities>
createProviderConfigFromJson({required String json}) Future<ProviderConfig>
createRateLimitConfigFromJson({required String json}) Future<RateLimitConfig>
createRerankRequestFromJson({required String json}) Future<RerankRequest>
createRerankResponseFromJson({required String json}) Future<RerankResponse>
createRerankResultDocumentFromJson({required String json}) Future<RerankResultDocument>
createRerankResultFromJson({required String json}) Future<RerankResult>
createResponseObjectFromJson({required String json}) Future<ResponseObject>
createResponseOutputItemFromJson({required String json}) Future<ResponseOutputItem>
createResponseToolFromJson({required String json}) Future<ResponseTool>
createResponseUsageFromJson({required String json}) Future<ResponseUsage>
createSearchRequestFromJson({required String json}) Future<SearchRequest>
createSearchResponseFromJson({required String json}) Future<SearchResponse>
createSearchResultFromJson({required String json}) Future<SearchResult>
createSpecificFunctionFromJson({required String json}) Future<SpecificFunction>
createSpecificToolChoiceFromJson({required String json}) Future<SpecificToolChoice>
createStreamChoiceFromJson({required String json}) Future<StreamChoice>
createStreamDeltaFromJson({required String json}) Future<StreamDelta>
createStreamFunctionCallFromJson({required String json}) Future<StreamFunctionCall>
createStreamOptionsFromJson({required String json}) Future<StreamOptions>
createStreamToolCallFromJson({required String json}) Future<StreamToolCall>
createSystemMessageFromJson({required String json}) Future<SystemMessage>
createToolCallFromJson({required String json}) Future<ToolCall>
createToolMessageFromJson({required String json}) Future<ToolMessage>
createTranscriptionResponseFromJson({required String json}) Future<TranscriptionResponse>
createTranscriptionSegmentFromJson({required String json}) Future<TranscriptionSegment>
createUsageFromJson({required String json}) Future<Usage>
createUserMessageFromJson({required String json}) Future<UserMessage>
createWaitForBatchConfigFromJson({required String json}) Future<WaitForBatchConfig>
decodeDataUrl({required String url}) Future<DecodedDataUrl?>
Decode a base64 data URL into DecodedDataUrl.
encodeDataUrl({required List<int> bytes, String? mime}) Future<String>
Encode bytes as a base64 data URL: data:<mime>;base64,<b64>.
ensureCryptoProvider() Future<void>
Install the ring crypto provider as the rustls process default, idempotently.
registerCustomProvider({required CustomProviderConfig config}) Future<void>
Register a custom provider in the global runtime registry.
unregisterCustomProvider({required String name}) Future<bool>
Remove a previously registered custom provider by name.