> ## 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](/integrations/auto-instrumentation) 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 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
```

## 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`.
</Note>

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:

<CodeGroup>
  ```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!"}]}'
  ```
</CodeGroup>

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


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