Skip to main content

Python SDK for tracing LLM calls (OpenAI, Anthropic, Google Gemini) to AmberTrace observability platform

Project description

AmberTrace Python SDK

Lightweight, zero-code LLM observability for Python. Trace every API call to OpenAI, Anthropic, and Google automatically.

Installation

# Core SDK
pip install ambertrace

# With specific provider support
pip install ambertrace[openai]
pip install ambertrace[anthropic]
pip install ambertrace[gemini]

# All providers
pip install ambertrace[all]

Requirements: Python 3.8+

Quick Start

import ambertrace
from openai import OpenAI

# Initialize once at startup
ambertrace.init(api_key="at_...")

# Use your LLM SDK as normal — tracing happens automatically
client = OpenAI()
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello!"}]
)

# Flush before exit
ambertrace.flush()

Supported Providers

Provider Models SDK
OpenAI GPT-5, GPT-4, GPT-4o, GPT-4o-mini, o1, o3 openai>=1.0.0
Anthropic Claude Opus 4.5/4.6, Sonnet 4.5, Haiku anthropic>=0.18.0
Google Gemini Pro, Flash, 2.0, Gemma google-generativeai>=0.3.0

Async Support

import asyncio
import openai
import ambertrace

async def main():
    ambertrace.init(api_key="at_...")
    client = openai.AsyncOpenAI()
    response = await client.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": "Hello!"}]
    )
    await ambertrace.flush_async()

asyncio.run(main())

Configuration

ambertrace.init(
    api_key="at_...",            # Required (or AMBERTRACE_API_KEY env var)
    environment="production",     # Environment tag for filtering
    debug=False,                  # Enable debug logging
    timeout=5.0,                  # Network timeout in seconds
    enabled=True,                 # Enable/disable tracing
)

API Reference

  • ambertrace.init() — Initialize SDK and start tracing
  • ambertrace.enable() / ambertrace.disable() — Toggle tracing at runtime
  • ambertrace.is_enabled() — Check if tracing is active
  • ambertrace.flush() — Block until pending traces are sent
  • ambertrace.flush_async() — Async version of flush
  • ambertrace.shutdown() — Flush, disable, and clean up

Links

License

Apache 2.0

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

ambertrace-0.1.0.tar.gz (41.2 kB view details)

Uploaded Source

Built Distribution

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

ambertrace-0.1.0-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ambertrace-0.1.0.tar.gz
  • Upload date:
  • Size: 41.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ambertrace-0.1.0.tar.gz
Algorithm Hash digest
SHA256 28aae3e2465baaaf9743772423f350c3659ad1eb6ceb29be7ae033503a55eef2
MD5 b3564a02cdc42c3fb5839d4ce4e982f3
BLAKE2b-256 640103776cceaf8aedfa9fc7d05eb0deaa375a7804f98e2165869eec015c3c97

See more details on using hashes here.

Provenance

The following attestation bundles were made for ambertrace-0.1.0.tar.gz:

Publisher: publish-python.yml on ambertrace/ambertrace-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: ambertrace-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ambertrace-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 10ba876540721e5aa0b86aad39463d7895c663249419c7826f9046cd63ac236c
MD5 431c88fc1fef3db16f8ef5c3342b9fef
BLAKE2b-256 54fa13890ff2daafb2a3907d3a5554484c98e31c685c6471aa57db306c0baf59

See more details on using hashes here.

Provenance

The following attestation bundles were made for ambertrace-0.1.0-py3-none-any.whl:

Publisher: publish-python.yml on ambertrace/ambertrace-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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