---
title: "Use Augure with the OpenAI Python SDK"
description: "Point the official openai Python package at Augure's Canadian, OpenAI-compatible API: change base_url and the key, keep your code."
tool: "OpenAI Python SDK"
category: "sdk"
canonical: "https://augureai.ca/docs/integrations/openai-python"
updated: "2026-10-26"
verified: false
---
# Use Augure with the OpenAI Python SDK

You get Augure as the model provider behind the official `openai` Python package: the same `chat.completions` calls, with inference on Canadian infrastructure.

## Prerequisites

- Python 3.8+ and `pip install openai`.
- An Augure API key (`aug_sk_live_…`) from the [developer dashboard](https://chat.augureai.ca/developers/dashboard). Plans and pricing: [augureai.ca/developers](https://augureai.ca/developers).
- The key exported as `AUGURE_API_KEY`.

## Configure

Two constructor arguments change. Everything else is unchanged.

```python test
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AUGURE_API_KEY"],
    base_url="https://api.augureai.ca/v1",
)

response = client.chat.completions.create(
    model="tofino-3",
    messages=[{"role": "user", "content": "Say hello in one short sentence."}],
    max_tokens=64,
)
print(response.choices[0].message.content)
```

If you prefer environment variables, the SDK reads `OPENAI_BASE_URL` and `OPENAI_API_KEY`, so `OpenAI()` with no arguments also works:

```bash
export OPENAI_BASE_URL=https://api.augureai.ca/v1
export OPENAI_API_KEY=aug_sk_live_...
```

Streaming, with usage in the final chunk:

```python
stream = client.chat.completions.create(
    model="rosedale-1",
    messages=[{"role": "user", "content": "Hello"}],
    stream=True,
    stream_options={"include_usage": True},
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
```

Tools (`tools=[...]`), `response_format`, `image_url` content parts and `file` content parts for PDFs all use the standard OpenAI request shape. See the [API reference](https://augureai.ca/docs/api).

## Pick a model

| Model | When to use |
| --- | --- |
| `ossington-5` | Flagship reasoning. 256K context, 32,768 max output. Default for hard tasks. |
| `rosedale-1` | Premium reasoning, up to 1M context on paid plans, Canadian inference. Long documents, agent loops. |
| `tofino-3` | Fast everyday model, 256K context, 16,384 max output, no thinking. Chat, extraction, classification. |

`model="auto"` lets the gateway pick. On `ossington-5`, `reasoning_effort="none"` turns thinking off and is the fastest setting for mechanical tasks; `low`, `medium` and `high` are accepted on reasoning models; `tofino-3` ignores it. When a model thinks, the reasoning comes back in `reasoning_content` on the message (`message.model_extra.get("reasoning_content")`). Full list: [/docs/models](https://augureai.ca/docs/models).

## Verify it works

```python test
import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["AUGURE_API_KEY"], base_url="https://api.augureai.ca/v1")
response = client.chat.completions.create(
    model="tofino-3",
    messages=[{"role": "user", "content": "Reply with the single word OK."}],
    max_tokens=64,
)
print(response.choices[0].message.content)
print(response.model_extra.get("_augure"))
```

The second line prints the `_augure` block that every response carries, for example `{'gateway_region': 'ca-montreal-1', 'inference_region': 'ca-on-toronto', 'request_id': '...'}`. `inference_region` tells you where the model ran. Inference is on Canadian infrastructure first, with disclosed failover to vetted EU partners under zero data retention, never the US.

## Notes

- The SDK keeps unknown response fields; read them through `model_extra` as above rather than by attribute if you use a type checker.
- OpenAI model aliases are accepted if you cannot change the model name yet: `gpt-4` and `gpt-4o` map to `ossington-4`, `gpt-4o-mini` and `gpt-3.5-turbo` map to `tofino-3`.
- `client.models.list()` returns the ids your key can use.
- Errors use the OpenAI error shape (`error.code`, for example `invalid_api_key` or `context_length_exceeded`), so the SDK's exception classes work unchanged.

## See also

- [API reference](https://augureai.ca/docs/api)
- [Models](https://augureai.ca/docs/models)
- [MCP server](https://augureai.ca/docs/mcp)
- [IDE setup](https://augureai.ca/docs/ide)
- [Pricing](https://augureai.ca/pricing)
