Skip to main content

Respan instrumentation plugin for LiteLLM

Project description

Respan LiteLLM Instrumentation

Respan instrumentation plugin for LiteLLM. It registers a LiteLLM CustomLogger callback and emits canonical Respan chat spans into respan-tracing.

Installation

pip install respan-ai respan-instrumentation-litellm litellm

Usage

import os

import litellm
from respan import Respan, workflow
from respan_instrumentation_litellm import LiteLLMInstrumentor

respan = Respan(
    api_key=os.environ["RESPAN_API_KEY"],
    app_name="litellm-example",
    instrumentations=[LiteLLMInstrumentor()],
)


@workflow(name="litellm_quickstart.workflow")
def run_completion() -> str:
    response = litellm.completion(
        api_key=os.environ["RESPAN_API_KEY"],
        api_base=os.getenv("RESPAN_GATEWAY_BASE_URL", "https://api.respan.ai/api"),
        model=os.getenv("RESPAN_MODEL", "gpt-4o-mini"),
        messages=[{"role": "user", "content": "Say hello in one sentence."}],
    )
    return response.choices[0].message.content


print(run_completion())
respan.flush()

Configuration

Parameter Type Default Description
include_content bool True Capture request messages and assistant response content on chat spans.

Use Respan(..., customer_identifier=..., thread_identifier=..., metadata=...) or respan.propagate_attributes(...) to attach Respan attributes to LiteLLM spans.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

respan_instrumentation_litellm-0.1.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

respan_instrumentation_litellm-0.1.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file respan_instrumentation_litellm-0.1.0.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_litellm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9cf4f4e2173c1c8cea5ad5bb397c04c504549133127a73c6f599b742e332306b
MD5 2078990cdda6fba8303b34ce388e0cc1
BLAKE2b-256 810b02d1f052638ebd8259a842777f30dafdcc0b175fce2271936b3ba64760fd

See more details on using hashes here.

File details

Details for the file respan_instrumentation_litellm-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for respan_instrumentation_litellm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69193b89230df7ab2ad19f7d09537a064814bf33e6269a69a00307853ef41b9e
MD5 698357fba43fa20e2c0a86387ba1e144
BLAKE2b-256 a2ab79c64c5ef87270605f2334e57d696a8ab51bb5ff6772d03cf8aff1eb9c06

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page