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

> ## Agent Instructions
> The Deepshi API is an OpenAI-compatible gateway. Base URL: https://api.deepshi.ai/v1. API keys start with sk-bf- and go in the Authorization: Bearer header. Prefer the official OpenAI SDKs pointed at the Deepshi base URL. Model ids are clean with no provider prefix (e.g. deepshi-3.0, claude-opus-4.8, gpt-5.5). Chat and image requests are synchronous; video and music requests are asynchronous job APIs (create, then poll). Every synchronous response carries usage.cost.total_cost in USD. Do not reference the internal /api/* admin plane or virtual keys.

# Authentication

> Create API keys and authenticate every request with a bearer token.

Every request to the Deepshi API is authenticated with an API key sent as a bearer token.

## API keys

You create and manage keys from your [Deepshi dashboard](https://deepshi.ai/). A key:

* Is shown **only once**, at creation. Store it immediately, because Deepshi can't show it to you again.
* Does **not** expire. It stays valid until you rotate, revoke, or delete it.

<Warning>
  Your key is a secret. Keep it server-side, load it from an environment
  variable, and never ship it in browser or mobile client code. If a key leaks,
  rotate or delete it from the dashboard right away.
</Warning>

## Authenticating requests

Send the key in the `Authorization` header as a bearer token:

```
Authorization: Bearer YOUR_DEEPSHI_API_KEY
```

<CodeGroup>
  ```bash curl theme={null}
  curl https://api.deepshi.ai/v1/chat/completions \
    -H "Authorization: Bearer $DEEPSHI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"model": "deepshi-3.0", "messages": [{"role": "user", "content": "Hi"}]}'
  ```

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

  client = OpenAI(
      base_url="https://api.deepshi.ai/v1",
      api_key="YOUR_DEEPSHI_API_KEY",
  )
  ```

  ```javascript JavaScript theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    baseURL: "https://api.deepshi.ai/v1",
    apiKey: process.env.DEEPSHI_API_KEY,
  });
  ```
</CodeGroup>

The SDK examples read the key from `DEEPSHI_API_KEY` in your environment. Set it with:

```bash theme={null}
export DEEPSHI_API_KEY="YOUR_DEEPSHI_API_KEY"
```

## Rotating and revoking keys

From the dashboard you can:

* **Rotate** a key to issue a new value and immediately invalidate the old one. Use this if a key may be compromised.
* **Revoke** a key to disable it without deleting it. Requests with a revoked key return `403`.
* **Delete** a key to remove it permanently.

## Authentication errors

| Status                 | Meaning                            | What to do                                                    |
| ---------------------- | ---------------------------------- | ------------------------------------------------------------- |
| `401 Unauthorized`     | Missing, malformed, or unknown key | Check the `Authorization` header and that the key is correct. |
| `403 Forbidden`        | Key was revoked or inactive        | Use an active key.                                            |
| `402 Payment Required` | Out of credits                     | [Top up your balance](/get-started/pricing-credits).          |

See [Errors & status codes](/resources/errors) for the full list.

## Next steps

<CardGroup cols={2}>
  <Card title="Credits & billing" icon="coins" href="/get-started/pricing-credits">
    How your prepaid balance and top-ups work.
  </Card>

  <Card title="Errors & status codes" icon="triangle-exclamation" href="/resources/errors">
    The full list of status codes and how to handle them.
  </Card>
</CardGroup>
