LiteRTLanguageModel

class LiteRTLanguageModel(val modelId: String, conversationFactory: LiteRTConversationFactory, settings: LiteRTLanguageModelSettings = LiteRTLanguageModelSettings(block = {})) : LanguageModel(source)

LanguageModel adapter for on-device LiteRT-LM engines.

The SDK prepares provider-neutral messages, tools, structured-output hints, sampler settings, and abort handling. The host supplies LiteRTConversationFactory to bind those requests to the platform engine. Streaming has no default deadline; configure ai.torad.aisdk.CallConfig.timeout at high-level call sites or the underlying engine timeout directly.

Since

0.3.0-beta01

Constructors

Link copied to clipboard
constructor(modelId: String, conversationFactory: LiteRTConversationFactory, settings: LiteRTLanguageModelSettings = LiteRTLanguageModelSettings(block = {}))

Properties

Link copied to clipboard
open override val modelId: String

Stable identifier for telemetry / routing ("litertlm/gemma-3-1b", "openai/gpt-5").

Link copied to clipboard
open override val provider: String

Provider tag for the model — "openai", "anthropic", "litert-lm", etc. Mirrors v6's LanguageModelV3.provider (per historical parity gap #40). Lets routing layers (a fallback chain, a tier picker) make provider-aware decisions without parsing modelId.

Link copied to clipboard
open override val supportedUrls: Map<String, List<String>>

Map of URL regex → media-tag list describing which URL shapes the provider accepts inline (so the agent doesn't have to download + base64-encode them itself). Mirrors v6's LanguageModelV3.supportedUrls. Empty default — most on-device providers don't accept URLs and fall back to base64.

Functions

Link copied to clipboard
open suspend override fun generate(params: LanguageModelCallParams): LanguageModelResult

One-shot completion. Requires explicit low-level opt-in at direct call sites.

Link copied to clipboard
open override fun stream(params: LanguageModelCallParams): Flow<StreamEvent>

Streaming completion. Cold until collected, then drives one upstream call per collection. Requires explicit low-level opt-in at direct call sites. Streaming has no default deadline; configure the provider transport or wrap the call in a higher-level CallConfig.timeout.

Link copied to clipboard

Streaming completion plus metadata available before stream collection. Implementations must keep the returned stream cold, and must not flowOn/emit from a foreign context — the collection context is the caller's choice. Providers can override this to expose request bodies and response headers while preserving the v6 doStream result shape.