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.1.0.tar.gz (11.8 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.1.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: doppel_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 11.8 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.1.0.tar.gz
Algorithm Hash digest
SHA256 3e8ad45e371045566e530014dd68fa418d817f63637636ac2c6eb123b29d9d00
MD5 7c10c88266b5b684888cc72d65630e6b
BLAKE2b-256 81ad84f378d10184652814453023381e2d985c21ecd0568807b3115fed98c41e

See more details on using hashes here.

Provenance

The following attestation bundles were made for doppel_sdk-0.1.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: doppel_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.4 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 324e8f865b0e8fe66af5cfd0e8222dffc0301dd0010de7b0a8b59d9652288d2c
MD5 28bb61fbec07a0f33ab663e510f2f7c2
BLAKE2b-256 a739d41bc75a4847baa5c696f7989f4ec44c15979ec73bf285e66dd645ca92a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for doppel_sdk-0.1.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