# Usage Tracking

> Monitor API usage and credit balance with your API key, plus richer dashboard reports.

Track how much of the API you are using and your remaining credit balance. Two endpoints are available directly with your API key; richer breakdowns are available through the dashboard API (JWT).

API-key endpoints — call these with Authorization: Bearer pxsk_…

## `GET /v1/account/usage`

Usage statistics for your account over a period.

**Auth:** API Key

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `period` | `string` | No | Window like 7d or 30d (pattern Nd, from 1d to 365d). Default 30d. |

**Response**

```json
{
  "total_requests": 150,
  "successful_requests": 145,
  "failed_requests": 5,
  "total_cost_usd": 3.24,
  "credits_used": 3240,
  "period_days": 30,
  "model_breakdown": {
    "gemini-3.1-flash-image-preview": 100,
    "fal-ai/bytedance/seedance/v2": 50
  }
}
```

## `GET /v1/account/me`

Your profile and current credit balance.

**Auth:** API Key

**Response**

```json
{
  "id": "9b1c7e0a-...",
  "email": "you@example.com",
  "name": "You",
  "role": "user",
  "is_active": true,
  "credits": { "balance": 6760, "total_earned": 10000, "total_used": 3240 }
}
```

> [!NOTE]
> The endpoints below are part of the dashboard API and require a browser session (JWT). They are not accessible with an API key.

## `GET /api/usage`

Aggregated usage including per-model breakdown and top endpoints.

**Auth:** Dashboard (JWT)

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `period` | `number` | No | Days, 1 to 365. Default 30. |

**Response**

```json
{
  "total_requests": 150,
  "successful_requests": 145,
  "failed_requests": 5,
  "total_credits_used": 3240,
  "period_days": 30,
  "model_breakdown": { "gemini-3.1-flash-image-preview": 100 },
  "top_endpoints": [ { "endpoint": "/v1/images/generate", "count": 100 } ]
}
```

## `GET /api/usage/daily`

Per-day usage breakdown for the period.

**Auth:** Dashboard (JWT)

## `GET /api/logs`

Paginated request logs: method, endpoint, status, latency, and credits.

**Auth:** Dashboard (JWT)

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | `number` | No | Page size, 1 to 100. Default 50. |
| `offset` | `number` | No | Pagination offset. Default 0. |

## `GET /api/tier`

Your tier limits — see Rate Limits.

**Auth:** Dashboard (JWT)

## Check your usage

**curl**

```bash
curl "https://api.picxstudio.com/v1/account/usage?period=30d" \
  -H "Authorization: Bearer pxsk_your_key"
```

**python**

```python
import requests

usage = requests.get(
    "https://api.picxstudio.com/v1/account/usage",
    headers={"Authorization": "Bearer pxsk_your_key"},
    params={"period": "30d"},
).json()
print(usage["credits_used"], "credits used")
```
