> ## 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.

# Cohere

> Scan Cohere Command traffic with the SDK auto-instrumentation, or through the PromptGuard proxy over HTTP

Use [auto-instrumentation](https://docs.promptguard.co/integrations/auto-instrumentation.md) if you call Cohere through its SDK: the PromptGuard SDKs patch `chat` on Cohere's `Client` and `ClientV2`, in Python (`cohere`) and Node (`cohere-ai`).

```python Python theme={"system"}
import promptguard
promptguard.init()  # reads PROMPTGUARD_API_KEY

import cohere
co = cohere.ClientV2()  # talks to Cohere directly; each chat call is scanned first
```

```typescript Node.js theme={"system"}
import { init } from 'promptguard-sdk';
import { CohereClientV2 } from 'cohere-ai';

init(); // reads PROMPTGUARD_API_KEY
const co = new CohereClientV2({}); // talks to Cohere directly; each chat call is scanned first
```

## Proxy

> [!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`.

Model ids starting `command-`, `c4ai-aya-`, `aya-` or `cohere-` go to Cohere. Send an OpenAI-style chat request to `/chat/completions`; PromptGuard forwards it to Cohere's v2 chat endpoint, `api.cohere.com/v2/chat`, and returns **Cohere's reply unchanged**, in Cohere's v2 shape (`message.content`), not OpenAI's (`choices`). An OpenAI client cannot read that reply, and the Cohere SDK cannot reach this route, so call it over plain HTTP:

```python Python theme={"system"}
import os
import httpx

response = httpx.post(
    "https://api.promptguard.co/api/v1/chat/completions",
    headers={
        "X-API-Key": os.environ["PROMPTGUARD_API_KEY"],
        "Authorization": f"Bearer {os.environ['CO_API_KEY']}",  # forwarded to Cohere
    },
    json={
        "model": "command-a-03-2025",
        "messages": [{"role": "user", "content": "Hello!"}],
    },
    timeout=60,
)
response.raise_for_status()
print(response.json()["message"]["content"][0]["text"])
```

```typescript Node.js theme={"system"}
const response = await fetch('https://api.promptguard.co/api/v1/chat/completions', {
  method: 'POST',
  headers: {
    'X-API-Key': process.env.PROMPTGUARD_API_KEY,
    Authorization: `Bearer ${process.env.CO_API_KEY}`, // forwarded to Cohere
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'command-a-03-2025',
    messages: [{ role: 'user', content: 'Hello!' }],
  }),
});
const reply = await response.json();
console.log(reply.message.content[0].text);
```

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

To keep the Cohere key out of your application, [store it as a provider key](https://docs.promptguard.co/gateway/provider-keys.md) under `cohere`.

## Next steps

> [card] [Auto-instrumentation](https://docs.promptguard.co/integrations/auto-instrumentation.md)
>
> Which provider calls `init()` patches, and which it does not

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

> [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.