Metadata-Version: 2.4
Name: continuum-ai-sdk
Version: 0.1.0
Summary: Thin client for the Continuum AI gateway: preconfigures the official OpenAI/Anthropic SDKs with the gateway's base_url and x-continuum-* headers (project, session, memory, compression).
License: MIT License
        
        Copyright (c) 2026 Continuum AI
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: openai
Requires-Dist: openai>=1.0; extra == "openai"
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.30; extra == "anthropic"
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Requires-Dist: openai>=1.0; extra == "test"
Requires-Dist: anthropic>=0.30; extra == "test"
Dynamic: license-file

# continuum-ai-sdk (Python SDK)

A thin wrapper around the official **openai** and **anthropic** Python SDKs: it
preconfigures their `base_url`, `api_key` and the gateway's `x-continuum-*` headers,
so your agent code stays plain SDK usage. There's no Continuum-specific request or
response type — `openai_client(...)` returns a real `openai.OpenAI`.

## Install

```bash
pip install continuum-ai-sdk[openai]  # or [anthropic], or both
```

## Use

```python
from continuum_ai import openai_client

client = openai_client(
    "https://proxy.continuum.ai",
    api_key,                 # your Continuum AI key (ck_live_...)
    project="billing-agent", # scopes shared memory and the usage dashboard
    session="run-42",        # scopes this one conversation
)

resp = client.chat.completions.create(model="continuum-smart", messages=[...])
```

Same shape for Anthropic:

```python
from continuum_ai import anthropic_client

client = anthropic_client("https://proxy.continuum.ai", api_key, project="billing-agent")
client.messages.create(model="continuum-smart", max_tokens=1024, messages=[...])
```

### Reading what the gateway did

The gateway reports routing, failovers and token savings as response headers
(never in the body — nothing about this is Continuum-specific JSON you'd have to
parse). Get at them with the SDK's `.with_raw_response`:

```python
from continuum_ai import parse_continuum_usage

raw = client.chat.completions.with_raw_response.create(model="continuum-smart", messages=[...])
usage = parse_continuum_usage(raw.headers)
print(usage.provider, usage.failovers, usage.tokens_saved)
completion = raw.parse()
```

### Memory and compression per call

```python
openai_client(url, key, memory="off")       # this call neither reads nor writes shared memory
openai_client(url, key, compression=False)  # send the raw, uncompressed context
```

`project` must match `[A-Za-z0-9_.:-]{1,128}` (same rule the gateway enforces) and is
validated client-side so a typo fails immediately instead of as an opaque 400.

## Development

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