Skip to main content

Official Doppel Python SDK

Project description

doppel-sdk — Python

Official Doppel SDK for Python. Wrap your existing LLM client and every call is captured and forwarded to Doppel — no change to your call sites.

Supports OpenAI, OpenRouter (and the OpenAI-compatible family: DeepSeek, Qwen, Grok, Mistral, …), Anthropic, and Google Gemini — across sync and async clients, and streaming and non-streaming calls. Zero runtime dependencies.

Install

pip install doppel-sdk

Usage

from doppel_sdk import DoppelClient
from openai import OpenAI

# Reads DOPPEL_API_KEY from the environment (or pass api_key=...).
doppel = DoppelClient(shadow_model="gpt-4o-mini")

client = doppel.wrap_openai(OpenAI())
client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello"}],
)

Other providers:

doppel.wrap_anthropic(Anthropic())        # messages.create
doppel.wrap_google(genai.Client())        # google-genai (or a GenerativeModel)
doppel.wrap_openrouter(OpenAI(base_url=".../openrouter"))

Async clients (AsyncOpenAI, AsyncAnthropic, client.aio.models) work the same way — the interceptor detects and handles them automatically. Streaming calls are captured too; for OpenAI/OpenRouter the SDK auto-enables stream_options.include_usage so token usage is recorded.

In short-lived processes (serverless, CLI), flush pending deliveries before exit:

doppel.flush()

Configuration

Setting Argument Environment variable Default
API key api_key DOPPEL_API_KEY — (required)
Server URL server_url DOPPEL_SERVER_URL https://api.doppel.in
Shadow model shadow_model none (chosen in the dashboard)
Debug logs debug DOPPEL_DEBUG (1/true) off

Development

pip install -e ".[dev]"
pytest

Publishing

Pushing a py-v* tag runs the tests, builds, and publishes to PyPI (trusted publishing — no token):

# bump version in pyproject.toml first, then:
git tag py-v0.1.0
git push origin py-v0.1.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

doppel_sdk-0.2.0.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

doppel_sdk-0.2.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file doppel_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: doppel_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for doppel_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 565447f7120a8ad888d5429ffb123cbedf11f01c9732481fb5f3df8c867e7b92
MD5 f1bec794a2ea69cb8404b95ed0281328
BLAKE2b-256 a37bf761eb1824c045807c6bd32e85e63e4bde531ccd70203cd9083d42d07bac

See more details on using hashes here.

Provenance

The following attestation bundles were made for doppel_sdk-0.2.0.tar.gz:

Publisher: publish-python.yml on doppelimpacttest/doppel-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 doppel_sdk-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: doppel_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for doppel_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 466cb0231f9715a7298f67b61dde614198c30fe1dcfbc6bac6b605d0d87958c3
MD5 92d1d75276040b088a33ef556e4e45fc
BLAKE2b-256 8417e6440c7ccc970e32a25fbbe9b4302714b786637dff2c323304d1942a46c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for doppel_sdk-0.2.0-py3-none-any.whl:

Publisher: publish-python.yml on doppelimpacttest/doppel-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