Skip to main content

Respan exporter for LiteLLM

Project description

Keywords AI LiteLLM Exporter

LiteLLM integration for exporting logs and traces to Keywords AI.

Installation

pip install keywordsai-exporter-litellm

Quick Start

Callback Mode

Use the callback to send traces to Keywords AI:

import litellm
from keywordsai_exporter_litellm import KeywordsAILiteLLMCallback

# Setup callback
callback = KeywordsAILiteLLMCallback(api_key="your-keywordsai-api-key")
callback.register_litellm_callbacks()

# Make LLM calls - traces are automatically sent
response = litellm.completion(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello!"}],
)

Proxy Mode

Route requests through Keywords AI gateway:

import litellm

response = litellm.completion(
    api_key="your-keywordsai-api-key",
    api_base="https://api.keywordsai.co/api",
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello!"}],
)

Logging

If you just want individual logs (no trace/span IDs), omit trace fields and send only basic metadata. This will produce one log per request.

Callback Mode (with keywordsai_params)

import litellm
from keywordsai_exporter_litellm import KeywordsAILiteLLMCallback

callback = KeywordsAILiteLLMCallback(api_key="your-api-key")
callback.register_litellm_callbacks()

response = litellm.completion(
    api_key="your-api-key",
    api_base="https://api.keywordsai.co/api",
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello!"}],
    metadata={
        "keywordsai_params": {
            "workflow_name": "simple_logging",
            "span_name": "single_log",
            "customer_identifier": "user-123",
        }
    },
)

Proxy Mode (with extra_body)

import litellm

response = litellm.completion(
    api_key="your-keywordsai-api-key",
    api_base="https://api.keywordsai.co/api",
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello!"}],
    extra_body={
        "span_workflow_name": "simple_logging",
        "span_name": "single_log",
        "customer_identifier": "user-123",
    },
)

License

MIT

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_exporter_litellm-1.0.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

respan_exporter_litellm-1.0.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file respan_exporter_litellm-1.0.0.tar.gz.

File metadata

  • Download URL: respan_exporter_litellm-1.0.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.8 Darwin/25.2.0

File hashes

Hashes for respan_exporter_litellm-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e0a807862bfce4863f1dc404fcf620d57c228d587d41466eaca66607e0b9f0a8
MD5 61a8a928d93a817a630c272da618caf9
BLAKE2b-256 fe49710b9f95eec50bceb9ec0ec301189634c732ab994285046818083c042917

See more details on using hashes here.

File details

Details for the file respan_exporter_litellm-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for respan_exporter_litellm-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 044268d27fe42a5aafee77527c3167039a9dd344cf103ea06625a26204547bcf
MD5 6bf35db4f6e4238bcfb8242728723fa4
BLAKE2b-256 e40d9fe853c88b175e79ec49b74de70a53f0f4ca45ecec3a6f2274d75c4e82d7

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