Skip to main content

Crate llm_api

Crate llm_api 

Source
Expand description

Canonical model invocation and continuation contract. No Agent or transport implementation.

Re-exports§

pub use service::Image;

Modules§

service

Structs§

BackendCapability
What one backend protocol can express, independent of any model. These are wire facts owned by the adapter, not catalog facts: a protocol that cannot carry a field makes the field unusable even when the model supports it.
Completion
Provider-neutral completion returned to Runtime.
CompletionRequest
One logical LLM invocation.
Continuation
Provider-issued replay data attached to exactly one completed model message. Adapters own the format and compatibility key. Callers must not synthesize or edit payloads.
EffectiveGeneration
Generation parameters that may reach the wire. Fields left None are omitted from the payload, which leaves the provider default in effect.
GenerationControls
What a settings UI may expose after intersecting catalog facts with the backend protocol. This is the same judgment resolve uses; a hidden control cannot appear on the wire, and a shown control is one the current backend can actually carry.
GenerationParameters
Deployment-owned generation settings, never supplied through Agent constraints. None leaves the setting unspecified. These are desired preferences. Adapters omit unsupported fields and clamp reasoning intensity onto the model’s list. Syntax validation does not establish model/provider support.
GenerationSupport
Confirmed per-model parameter support from catalog metadata.generationSupport. Missing information never establishes support; it is never inferred from preferences. Unknown catalog keys are ignored so a newer catalog cannot break an older client.
Message
Provider-neutral conversation message.
ModelCapabilities
Confirmed model capabilities. Missing information never establishes support.
ModelConstraints
Caller-declared requirements. Listed input modalities and true flags require confirmed support; an empty input list and false flags impose no requirement. Adapters must not infer or override these declarations from message content.
ModelMode
Logical model mode selected by the product, independent of provider and model identifiers.
ModelProfile
Provider-neutral limits for one frozen logical model route.
TokenUsage
Normalized token accounting reported by an implementation.
ToolCall
Tool call returned by an LLM.
ToolDefinition
A callable function exposed to the model. Execution policy belongs to the caller.
UseCase
Logical model use case resolved by the deployment’s LLM implementation.

Enums§

ContentPart
One typed part of a model message.
FinishReason
Why a model invocation stopped.
MessageRole
Role of a message in a model conversation.

Constants§

DEFAULT_MAX_OUTPUT_TOKENS
Internal per-response output cap. Not a user setting. Adapters omit it when the model snapshot says maxTokens is false.
INPUT_AUDIO
Audio input.
INPUT_FILE
Generic file input.
INPUT_IMAGE
Closed vocabulary for non-text model input. text is implied and must not be listed.
INPUT_VIDEO
Video input.
MESSAGE_SCHEMA
Offline normative schema for persisted model messages.
REASONING_EFFORT_LADDER
Reasoning intensity ordered from least to most. Turning thinking off is the thinking switch, never a listed intensity, so none is not on this ladder.

Functions§

controls
Settings that can take effect on this backend for this model. Callers must not infer controls from catalog fields alone.
input_modality_for_kind
Closed-vocabulary token for an artifact kind.
input_modality_for_mime
Closed-vocabulary token for a MIME type. Non-media types map to file.
normalize_capability_input
Normalizes catalog capability tokens. text is ignored; unknown tokens fail.
normalize_constraint_input
Normalizes caller-declared constraint tokens. text is illegal here.
normalize_input_token
Maps one catalog/constraint token. text is dropped. vision and unknown values fail.
payload_input_modalities
Distinct payload modalities required by Artifact and Image parts.
resolve
The single resolution of desired generation parameters against model and protocol facts. Every caller resolves exactly once, against facts frozen for the request, so replaying a frozen route always yields the same wire payload.