LiteLLMConsumptionCapturingPromptExecutor

LiteLLM variant: reads inputTokensCount / outputTokensCount / totalTokensCount from the first response that carries token metadata.

LiteLLM populates these fields on the first (and typically only) response in the list; subsequent responses are tool-call objects with no token data.

Constructors

constructor(delegate: PromptExecutor)

Functions

Link copied to clipboard
open override fun close()

Closes the underlying delegate executor.

Link copied to clipboard
open override fun collectAndClear(): LLMConsumption?

Returns the consumption accumulated since the previous call (or since construction), then resets the accumulator. Returns null when nothing was captured.

Link copied to clipboard
open suspend override fun execute(prompt: Prompt, model: LLModel, tools: List<ToolDescriptor>): List<Message.Response>

Runs the call through delegate and accumulates any LLMConsumption reported by extractConsumption for the returned responses. Accumulation is thread-safe.

fun execute(prompt: Prompt, model: LLModel, tools: List<ToolDescriptor>, executorService: ExecutorService?): List<Message.Response>
Link copied to clipboard
fun executeMultipleChoices(prompt: Prompt, model: LLModel, tools: List<ToolDescriptor>, executorService: ExecutorService?): List<LLMChoice>
open suspend fun executeMultipleChoices(prompt: Prompt, model: LLModel, tools: List<ToolDescriptor>): List<LLMChoice>
Link copied to clipboard
open override fun executeStreaming(prompt: Prompt, model: LLModel, tools: List<ToolDescriptor>): Flow<StreamFrame>

Delegates streaming to delegate; no consumption is captured from streamed frames.

Link copied to clipboard
fun executeStreamingWithPublisher(prompt: Prompt, model: LLModel, tools: List<ToolDescriptor>): Flow.Publisher<StreamFrame>
Link copied to clipboard
inline suspend fun <OutputStructT> PromptExecutor.executeStructuredOrThrow(prompt: Prompt, model: LLModel): OutputStructT

Executes prompt against model, requesting a structured response of type OutputStructT, and returns the parsed data.

Link copied to clipboard
open fun getBasicJsonSchemaGenerator(model: LLModel): BasicJsonSchemaGenerator
Link copied to clipboard
open fun getStandardJsonSchemaGenerator(model: LLModel): StandardJsonSchemaGenerator
Link copied to clipboard
fun models(executorService: ExecutorService?): List<LLModel>
open suspend fun models(): List<LLModel>
Link copied to clipboard
open suspend override fun moderate(prompt: Prompt, model: LLModel): ModerationResult

Delegates moderation to delegate; no consumption is captured.

fun moderate(prompt: Prompt, model: LLModel, executorService: ExecutorService?): ModerationResult