Skip to content

LiteLLM

Logfire supports instrumenting calls to the LiteLLM Python SDK with the logfire.instrument_litellm() method.

Installation

Install logfire with the litellm extra:

Terminal
pip install 'logfire[litellm]'

Usage

import litellm

import logfire

logfire.configure()
logfire.instrument_litellm()

response = litellm.completion(
    model='gpt-5-mini',
    messages=[{'role': 'user', 'content': 'Hi'}],
)
print(response.choices[0].message.content)
#> Hello! How can I assist you today?

This creates a span which shows the conversation in the Logfire UI:

Logfire LiteLLM conversation

logfire.instrument_litellm() uses the LiteLLMInstrumentor().instrument() method of the openinference-instrumentation-litellm package.