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

# OpenAI-compatible hosts

> Scan OpenRouter, Together, Fireworks, xAI, Perplexity, Cerebras, SambaNova, Nebius, DeepInfra or your own OpenAI-compatible server through the PromptGuard proxy

Services that speak OpenAI's wire format differ only in their host, so one adapter serves all of them. You pick it with a vendor namespace on the model id, and PromptGuard sends the request to the host stored with your provider key.

| Namespace | For |
| - | - |
| `openrouter/` | OpenRouter |
| `together/` | Together AI |
| `fireworks/` | Fireworks AI |
| `xai/` | xAI |
| `perplexity/` | Perplexity |
| `cerebras/` | Cerebras |
| `sambanova/` | SambaNova |
| `nebius/` | Nebius |
| `deepinfra/` | DeepInfra |
| `openai-compatible/` | Any other server with an OpenAI-compatible API |

The namespace is removed before forwarding: `openrouter/anthropic/claude-sonnet-4.5` reaches OpenRouter as `anthropic/claude-sonnet-4.5`.

## 1. Store the key with its host

The host is never taken from the request. It is stored with the key, so a caller cannot send your key somewhere else. In [**Dashboard → Connect → Provider Keys**](https://app.promptguard.co/dashboard/provider-keys) **→ Add provider key**, choose **OpenAI-compatible**, paste the key and enter the service's endpoint under **Base URL**. Or through the [provider keys API](https://docs.promptguard.co/gateway/provider-keys.md#storing-a-key), as an `openai_compatible` key with the endpoint in `base_url`:

```bash theme={"system"}
curl -X POST https://api.promptguard.co/dashboard/provider-keys \
  -H "Authorization: Bearer $DASHBOARD_TOKEN" \
  -H "X-CSRF-Token: $CSRF" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "openai_compatible",
    "name": "OpenRouter",
    "key": "<your OpenRouter key>",
    "base_url": "https://openrouter.ai/api/v1"
  }'
```

The `base_url` must not contain credentials, and it must not be a link-local address such as the cloud metadata service.

**On PromptGuard Cloud the host must be on the public internet, over `https`.** Cloud calls it from its own network, which is shared by every customer, so it refuses an internal destination: `localhost` and other loopback addresses, private ranges such as `10.0.0.0/8` and `192.168.0.0/16`, `0.0.0.0`, IPv6 loopback and unique-local addresses, cloud metadata hosts such as `metadata.google.internal`, names ending `.internal`, `.local` or `.localhost`, and an address written as a number (`2130706433`, `0x7f000001`, `127.1`). It is refused when you save the key, again before each request, and once more when the connection opens: the name is resolved then, every address it has must be public, and the request goes to the address that was checked, so a name that later resolves to an internal address is refused too. A request refused this way gets a 400 and nothing is sent.

**On a self-hosted install or a [Hybrid](https://docs.promptguard.co/production/self-host-vs-cloud.md) data plane**, the host may be a private or loopback address, such as an on-prem vLLM or Ollama server, and plain `http` is allowed for one. A public host still has to use `https`, so your key never crosses the internet in clear.

> [!NOTE]
>
> The namespace picks the adapter, not the host. Every namespace resolves to the same stored `openai_compatible` key: the most recent active one for the project, or failing that for your account. To use two of these services, put them in separate projects.

## 2. Send the request

> [!NOTE]
>
> **Proxy Base URL:** `https://api.promptguard.co/api/v1`
>
> Point your LLM SDK's `base_url` / `baseURL` to this endpoint. Your existing provider API key goes in the `Authorization` header as usual; add your PromptGuard key via `X-API-Key`.

```python Python theme={"system"}
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.promptguard.co/api/v1",
    api_key="unused",  # PromptGuard replaces it with the stored key
    default_headers={"X-API-Key": os.environ["PROMPTGUARD_API_KEY"]},
)

response = client.chat.completions.create(
    model="openrouter/anthropic/claude-sonnet-4.5",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
```

```typescript Node.js theme={"system"}
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.promptguard.co/api/v1',
  apiKey: 'unused', // PromptGuard replaces it with the stored key
  defaultHeaders: { 'X-API-Key': process.env.PROMPTGUARD_API_KEY },
});

const response = await client.chat.completions.create({
  model: 'openrouter/anthropic/claude-sonnet-4.5',
  messages: [{ role: 'user', content: 'Hello!' }],
});
```

```bash cURL theme={"system"}
curl https://api.promptguard.co/api/v1/chat/completions \
  -H "X-API-Key: $PROMPTGUARD_API_KEY" \
  -H "Authorization: Bearer unused" \
  -H "Content-Type: application/json" \
  -d '{"model": "openrouter/anthropic/claude-sonnet-4.5", "messages": [{"role": "user", "content": "Hello!"}]}'
```

The OpenAI client refuses to start without an `api_key`, so give it any value; PromptGuard sends the stored key instead. Without a stored `openai_compatible` key the request fails, because there is no host to send it to.

## Next steps

> [card] [Provider keys](https://docs.promptguard.co/gateway/provider-keys.md)
>
> Store your provider credentials once, forwarded server-side

> [card] [Routing rules](https://docs.promptguard.co/gateway/routing-rules.md)
>
> Rewrite the upstream provider or model per request

> [card] [Integrations overview](https://docs.promptguard.co/integrations/overview.md)
>
> Every provider and framework, and how to connect each


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