> ## Documentation Index
> Fetch the complete documentation index at: https://docs.os3compute.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Gateway setup

> Send the calls your app already makes through OS3.

Same API key, same model ids. OS3 [stores](https://docs.os3compute.com/data.md) each request and answer; a [trained model](https://docs.os3compute.com/training.md#trained-models) can later answer under the same model id.

```python Python wrap theme={null}
import os

from openai import OpenAI

client = OpenAI(  # api_key: your app's own, unchanged
    base_url="https://gateway.os3compute.com/v1",
    default_headers={"x-os3-key": os.environ["OS3_GATEWAY_KEY"]},
)
reply = client.chat.completions.create(
    model="<your model>",
    messages=[{"role": "user", "content": "Hello"}],
    extra_headers={"x-os3-subject": "user-123"},  # optional
)
```

| | |
| - | - |
| Base URL | OpenAI SDK: `https://gateway.os3compute.com/v1`. Anthropic SDK: `https://gateway.os3compute.com`. |
| Goes to | The SDK's own API. Another of that shape: its base URL after `/p/`, as `https://gateway.os3compute.com/p/api.example.com/v1`. |
| `x-os3-key` | [Gateway key](https://docs.os3compute.com/keys.md) |
| `x-os3-subject` | End user's id; not passed on. A trained model's share keeps each user on one side. |
| No code change | `/k/<url-key>` after the host: `https://gateway.os3compute.com/k/<url-key>/v1`. URL key: secret, shown once beside a new gateway key. |
| Paths | `/v1/chat/completions`, `/v1/responses`, `/v1/embeddings`, `/v1/messages`; streams too |
| Cost | None from OS3. Your key pays its API as before. |
| Limits | [Per key](https://docs.os3compute.com/errors.md#limits) |
| Errors | The API's own, passed on. [OS3's](https://docs.os3compute.com/errors.md#errors). |
| Request id | `x-os3-request-id` response header |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.