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

# Credits & billing

> How your prepaid balance, top-ups, and usage metering work.

The Deepshi API is **prepaid and usage-based**. You add credits to your account, and each request draws down your balance based on what it uses.

## Credits

* Your account holds a single credit **balance**, shared by all of your API keys.
* Credits are denominated in **USD**.
* Add credits from your [Deepshi dashboard](https://deepshi.ai/). Top-ups apply immediately.
* Failed requests (4xx) are **not** billed.

<Tip>
  Because every key shares one balance, you can issue separate keys per app or
  environment without splitting your credits across them.
</Tip>

## How usage is priced

Pricing is **per model**, shown on [deepshi.ai](https://deepshi.ai/) in USD. Text models are priced per token, with separate input and output rates per 1M tokens. Image models are priced per generated image or per megapixel, and for some models the rate depends on the resolution or quality you request. Video models are priced per second of output, and music models per track or per minute.

Every response reports the exact amount in `usage.cost.total_cost`, shown below.

## Knowing exactly what a request cost

Every successful response includes a `usage` object. Deepshi adds **`usage.cost.total_cost`**, the exact USD amount the request deducted from your balance:

```json theme={null}
"usage": {
  "prompt_tokens": 22,
  "prompt_tokens_details": { "cached_tokens": 0 },
  "completion_tokens": 8,
  "total_tokens": 30,
  "cost": { "total_cost": 0.000135 }
}
```

When streaming, the final chunk carries the same `usage` object, including `cost`. Standard OpenAI SDKs ignore the extra `cost` field, so it doesn't break compatibility.

## Checking your balance

Your current balance, spend, and per-request history are in the [dashboard](https://deepshi.ai/). Usage is metered in near real time; the displayed balance may lag actual usage by a few seconds under heavy load.

## Running out of credits

When your balance is exhausted, requests fail with `402`:

```json theme={null}
{
  "error": {
    "code": "insufficient_quota",
    "message": "You have insufficient credits to complete this request.",
    "param": null,
    "type": "insufficient_quota"
  }
}
```

Top up your balance to resume. See [Errors & status codes](/resources/errors) for handling this in code.

## Next steps

<CardGroup cols={2}>
  <Card title="Errors & status codes" icon="triangle-exclamation" href="/resources/errors">
    Handle `402` and the other status codes in code.
  </Card>

  <Card title="Models" icon="cubes" href="/models/overview">
    Browse every model and how each one is priced.
  </Card>
</CardGroup>
