LiteLlm class

OpenAI-compatible adapter that targets LiteLLM providers.

Inheritance

Constructors

LiteLlm({required String model, String customProvider = '', LiteLlmCompletionsInvoker? completionsInvoker, LiteLlmGenerateHook? generateHook, String? apiKey, String? baseUrl})
Creates a LiteLLM adapter for model.

Properties

apiKey String?
Optional API key for remote completions request when using default invoker.
final
baseUrl String?
Optional base URL of the completions API when using default invoker.
final
capabilities LlmCapabilities
Self-reported capabilities snapshot for this LLM instance.
no setterinherited
completionsInvoker LiteLlmCompletionsInvoker?
Optional invoker for completions responses.
final
customProvider String
Optional explicit provider name override.
final
hashCode int
The hash code for this object.
no setterinherited
model String
The model identifier sent to the backend.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

generateContent(LlmRequest request, {bool stream = false}) Stream<LlmResponse>
Generates model responses using LiteLLM payload/response conventions.
override
maybeAppendUserContent(LlmRequest request) → void
Appends a fallback user turn when request has no trailing user content.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

buildPayload(LlmRequest request, {required bool stream}) Map<String, Object?>
Builds a LiteLLM/OpenAI-style request payload from request.
getProviderFromModel(String model) String
Infers the LiteLLM provider from model.
mapFinishReason(Object? finishReason) String
Maps provider-specific finish reasons to ADK finish reason values.
parseCompletionResponse(Map<String, Object?> response) LlmResponse
Parses one LiteLLM completion response into LlmResponse.
supportedModels() List<RegExp>
Regex patterns supported by this adapter.