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

# Connect to the Gateway

> How to route any LLM SDK through the Wardin gateway.

The Wardin gateway speaks the Anthropic Messages API format. Point any compatible SDK at the gateway URL and swap in your virtual key — no other code changes.

## Gateway URL

```
https://gw.wardin.ai
```

## Authentication

The gateway accepts your virtual key in either header, so SDK defaults just work:

* `Authorization: Bearer wardin_sk_...` (canonical — what the OpenAI SDK and most tools send)
* `x-api-key: wardin_sk_...` (what the Anthropic SDK's `api_key` mode sends)

## Supported protocols

| Protocol                | Endpoint               | Use for                               |
| ----------------------- | ---------------------- | ------------------------------------- |
| Anthropic Messages API  | `/v1/messages`         | Claude models                         |
| OpenAI Chat Completions | `/v1/chat/completions` | GPT models, OpenAI-compatible clients |
| Embeddings              | `/v1/embeddings`       | Text embedding models                 |

## SDK examples

<CodeGroup>
  ```bash cURL (Anthropic) theme={null}
  curl https://gw.wardin.ai/v1/messages \
    -H "Authorization: Bearer wardin_sk_YOUR_KEY" \
    -H "anthropic-version: 2023-06-01" \
    -H "content-type: application/json" \
    -d '{
      "model": "claude-opus-4-8",
      "max_tokens": 1024,
      "messages": [{"role": "user", "content": "Hello"}]
    }'
  ```

  ```python Python (Anthropic SDK) theme={null}
  import anthropic

  client = anthropic.Anthropic(
      api_key="wardin_sk_YOUR_KEY",
      base_url="https://gw.wardin.ai",
  )
  ```

  ```python Python (OpenAI SDK) theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="wardin_sk_YOUR_KEY",
      base_url="https://gw.wardin.ai/v1",
  )
  ```

  ```typescript TypeScript (Anthropic SDK) theme={null}
  import Anthropic from '@anthropic-ai/sdk';

  const client = new Anthropic({
    apiKey: 'wardin_sk_YOUR_KEY',
    baseURL: 'https://gw.wardin.ai',
  });
  ```

  ```typescript TypeScript (OpenAI SDK) theme={null}
  import OpenAI from 'openai';

  const client = new OpenAI({
    apiKey: 'wardin_sk_YOUR_KEY',
    baseURL: 'https://gw.wardin.ai/v1',
  });
  ```

  ```bash Environment variables theme={null}
  # Anthropic tooling (either variable works; AUTH_TOKEN is idiomatic for proxies)
  export ANTHROPIC_AUTH_TOKEN=wardin_sk_YOUR_KEY
  export ANTHROPIC_BASE_URL=https://gw.wardin.ai

  # OpenAI tooling
  export OPENAI_API_KEY=wardin_sk_YOUR_KEY
  export OPENAI_BASE_URL=https://gw.wardin.ai/v1
  ```
</CodeGroup>

## Streaming

Streaming works without any changes. The gateway transparently forwards server-sent events (SSE) from the provider to your client. Token usage is parsed from the final `message_delta` event for billing.

```python theme={null}
with client.messages.stream(
    model="claude-opus-4-8",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Tell me a story"}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
```

## Request attribution headers

Add these optional headers to improve analytics granularity:

| Header                       | Description                                                     |
| ---------------------------- | --------------------------------------------------------------- |
| `X-Wardin-Session-Id`        | Groups multiple requests into a session (e.g., one coding task) |
| `X-Wardin-Prompt-Id`         | Links the request to a prompt in the Prompt Registry            |
| `X-Wardin-Prompt-Version-Id` | Pins the request to a specific prompt version                   |

If `X-Wardin-Session-Id` is not provided, the gateway groups requests using idle-timeout bucketing (30-minute sliding window). See [Sessions](/concepts/sessions).

User attribution comes from the virtual key's owner — issue one key per developer rather than sharing keys.

## Response headers

| Header           | Description                                                                                                 |
| ---------------- | ----------------------------------------------------------------------------------------------------------- |
| `X-Wardin-Cache` | Present when the response was served from cache: `HIT` (L1 exact match) or `SEMANTIC` (L2 similarity match) |

## Health check

```bash theme={null}
curl https://gw.wardin.ai/health
# {"status":"ok"}
```
