OpenInference LiteLLM Instrumentation
LiteLLM allows developers to call all LLM APIs using the openAI format. LiteLLM Proxy is a proxy server to call 100+ LLMs in OpenAI format. Both are supported by this auto-instrumentation.
This package implements OpenInference tracing for the following LiteLLM functions:
- completion()
- acompletion()
- completion_with_retries()
- embedding()
- aembedding()
- image_generation()
- aimage_generation()
- anthropic.messages.create()
- anthropic.messages.acreate()
These traces are fully OpenTelemetry compatible and can be sent to an OpenTelemetry collector for viewing, such as Arize Phoenix or Arize AX.
Installation
pip install openinference-instrumentation-litellm
Quickstart
In a notebook environment (jupyter, colab, etc.) install openinference-instrumentation-litellm if you haven't already as well as arize-phoenix and litellm.
pip install openinference-instrumentation-litellm arize-phoenix litellm
First, import dependencies required to autoinstrument liteLLM and set up phoenix as an collector for OpenInference traces.
import litellm
import phoenix as px
from openinference.instrumentation.litellm import LiteLLMInstrumentor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
Next, we'll start a phoenix server and set it as a collector.
session = px.launch_app()
endpoint = "http://127.0.0.1:6006/v1/traces"
tracer_provider = TracerProvider()
tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))
Set up any API keys needed in you API calls. For example:
import os
os.environ["OPENAI_API_KEY"] = "PASTE_YOUR_API_KEY_HERE"
Instrumenting LiteLLM is simple:
LiteLLMInstrumentor().instrument(tracer_provider=tracer_provider)
Now, all calls to LiteLLM functions are instrumented and can be viewed in the phoenix UI.
completion_response = litellm.completion(model="gpt-3.5-turbo",
messages=[{"content": "What's the capital of China?", "role": "user"}])
print(completion_response)
acompletion_response = await litellm.acompletion(
model="gpt-3.5-turbo",
messages=[{ "content": "Hello, I want to bake a cake","role": "user"},
{ "content": "Hello, I can pull up some recipes for cakes.","role": "assistant"},
{ "content": "No actually I want to make a pie","role": "user"},],
temperature=0.7,
max_tokens=20
)
print(acompletion_response)
embedding_response = litellm.embedding(model='text-embedding-ada-002', input=["good morning!"])
print(embedding_response)
image_gen_response = litellm.image_generation(model='dall-e-2', prompt="cute baby otter")
print(image_gen_response)
You can also uninstrument the functions as follows
LiteLLMInstrumentor().uninstrument(tracer_provider=tracer_provider)
Now any liteLLM function calls you make will not send traces to Phoenix until instrumented again
More Info
Metadata
Release files for openinference-instrumentation-litellm 0.1.48
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| openinference_instrumentation_litellm-0.1.48.tar.gz | 115.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openinference_instrumentation_litellm-0.1.48-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 141.4 kB
Release files / openinference_instrumentation_litellm-0.1.48.tar.gz
| Download URL | openinference_instrumentation_litellm-0.1.48.tar.gz |
|---|---|
| Size | 115.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f5a955776c2fa2a9d606e1cf0a0106d6c9e19034eb1bfdb3de62cdb0199a440b
|
|
BLAKE2b-256 checksum How to use checksums |
cf0f9b80edc82f1a7488d5c79e94fad3bd438621bfb4940ab9dc2be53e9d0c3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.
Transparency logRelease files / openinference_instrumentation_litellm-0.1.48-py3-none-any.whl
| Download URL | openinference_instrumentation_litellm-0.1.48-py3-none-any.whl |
|---|---|
| Size | 26.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b1c9d171442fb57c68f78bf914aa86a3ff847deaa2d6839f77e0944f41c479a0
|
|
BLAKE2b-256 checksum How to use checksums |
94416377b396b1a6bf5a290b581189de3ca08da0eb3e2dbf12b64ec89dc8d45b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.
Transparency log