Metadata-Version: 2.4
Name: doppel-sdk
Version: 0.1.0
Summary: Official Doppel Python SDK
License: MIT
Keywords: api,doppel,llm,sdk,shadow,testing
Requires-Python: >=3.9
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-asyncio; extra == 'dev'
Description-Content-Type: text/markdown

# 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

```bash
pip install doppel-sdk
```

## Usage

```python
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:

```python
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:

```python
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

```bash
pip install -e ".[dev]"
pytest
```

## Publishing

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

```bash
# bump version in pyproject.toml first, then:
git tag py-v0.1.0
git push origin py-v0.1.0
```
