# Get balance

`GET https://my.neuronai.uz/api/v1/balance`

API maʼlumotnomasi › Balans va sarf

Returns the remaining credits for the calling key's organization. Use it to surface a low balance before a request fails with `402`.

**Authentication:** `Authorization: Bearer <API key>`, a key with `account:read`.

## Javob (200, `application/json`)

The organization's remaining balance.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | object | Yes |  |
| `data.balance` | number | Yes |  |
| `data.formatted` | string | Yes |  |
| `data.currency` | string | Yes |  |
| `data.stt_price_per_second` | number | Yes | Credits per second of audio transcribed, at your organization's price. |
| `data.stt_price_per_minute` | number | Yes | Deprecated: use `stt_price_per_second`. The same rate, times 60. |
| `data.tts_price_per_char` | number | Yes | Credits per character of speech in a stock voice, at your organization's price. |
| `data.min_topup` | number | Yes |  |
| `data.credit_limit` | number | Yes |  |
| `request_id` | string | Yes |  |

```json
{
  "data": {
    "balance": 987.4,
    "formatted": "string",
    "currency": "string",
    "stt_price_per_second": 0,
    "stt_price_per_minute": 0,
    "tts_price_per_char": 0,
    "min_topup": 0,
    "credit_limit": 0
  },
  "request_id": "7c4a8d09-ca37-4f3c-9e2b-1b0f3c2a9d41"
}
```

### Sarlavhalar

| Header | Type | Description |
| --- | --- | --- |
| `X-Request-Id` | string | Identifies this request. A JSON body carries it as `request_id` too; quote it to support. |
| `X-RateLimit-Limit` | integer | The requests a minute the rate limit on this endpoint allows. Sent once the limit has counted the request, so not when the key itself is refused. |
| `X-RateLimit-Remaining` | integer | How many of them are left this minute. |

## Xatolar

Every error has the same JSON shape:

```json
{
  "error": {
    "type": "invalid_request_error",
    "code": "invalid_request",
    "message": "The request is malformed or failed validation.",
    "param": null
  },
  "request_id": "7c4a8d09-ca37-4f3c-9e2b-1b0f3c2a9d41"
}
```

| Status | Meaning |
| --- | --- |
| 401 | The API key is missing or not recognized (`invalid_api_key`), revoked (`api_key_revoked`), disabled (`api_key_disabled`) or expired (`api_key_expired`). |
| 403 | The key lacks the permission this endpoint needs (`insufficient_permissions`), or the client IP is not in its allowlist (`ip_not_allowed`). |
| 429 | A rate or concurrency limit was reached (`rate_limit_exceeded`, `concurrency_limit_exceeded`). Retry after `Retry-After` seconds. |
| default | Any other error, in the same shape, such as `server_error` (500) or `service_unavailable` (503). |

## Examples

### cURL

```bash
# Your balance, in credits
curl "https://my.neuronai.uz/api/v1/balance" \
  -H "Authorization: Bearer <your-api-key>"

# Spend and request counts over the last 30 days
curl "https://my.neuronai.uz/api/v1/usage?days=30" \
  -H "Authorization: Bearer <your-api-key>"
```

### TypeScript SDK

```typescript
import {NeuronAI} from "@naiuz/sdk";

const client = new NeuronAI();

const balance = await client.account.balance();

console.log(balance.formatted);
```

### Python SDK

```python
from naiuz import NeuronAI

client = NeuronAI()

balance = client.account.balance()

print(balance.formatted)
```

### PHP SDK

```php
$client = new \Naiuz\NeuronAI();

$balance = $client->account->balance();

echo $balance->formatted, PHP_EOL;
```

### JavaScript

```javascript
const response = await fetch('https://my.neuronai.uz/api/v1/usage?days=30', {
  headers: { Authorization: 'Bearer <your-api-key>' },
});

const { data } = await response.json();
const { total, by_service: byService } = data;
```

---

Source: https://docs.neuronai.uz/uz/api/reference/account/retrieve-balance
