# Get a workspace's AI credit

> A workspace's AI credit, which pays for agent and AI gateway usage: what is left (balance_micros), how much of it was bought and given, its grants newest first, whether new runs on g1t's models are refused for want of it (blocked), whether it can be bought (can_buy) and for how much (min_cents, max_cents, presets_cents, and the card_fee added on top), auto-reload, the agent rate and the markups on models.

<div class="g1t-endpoint"><span class="g1t-method" data-method="get">GET</span><code>/workspaces/{workspace}/ai_credit</code></div>

`free_via_discount` or `postpaid` mean no credit is needed. Members of the workspace only.

`card_fee.percent_micros` is per dollar charged, in millionths: 29000 is 2.9%. `blocked` is true when the credit has run out and new runs on g1t's models wait for more; runs on a model provider the workspace connected itself never need it.

- **Authentication:** Required. Send an [access token](/reference/api/#authentication) as `Authorization: Bearer`.
- **MCP tool:** [`billing`](/reference/mcp/#billing) with `action` `ai_credit`, and the same inputs
- **Scope:** An access token needs [`billing:read`](/guides/authentication/#scopes).

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `workspace` | string | Yes | The workspace's slug, e.g. "flagon-io". |

## Example request

```sh
curl https://api.g1t.sh/workspaces/flagon-io/ai_credit \
  -H "Authorization: Bearer $G1T_TOKEN"
```

## Example response

A successful request answers `200` with:

```json
{
  "balance_micros": 62000000,
  "purchased_micros": 50000000,
  "given_micros": 12000000,
  "grants": [
    {
      "id": "crd_01kkr2m4c8f1t7qh3d6n9w5p0x",
      "workspace": "flagon-io",
      "kind": "purchase",
      "amount_micros": 50000000,
      "used_micros": 0,
      "left_micros": 50000000,
      "note": "AI credit bought",
      "refund_for": null,
      "refund_day": null,
      "expires_at": "2027-10-02T00:00:00.000Z",
      "created_by": "ana",
      "created_at": "2026-10-02T16:20:00.000Z",
      "state": "open",
      "closed_at": null,
      "closed_note": null,
      "closed_by": null
    }
  ],
  "free_via_discount": false,
  "postpaid": false,
  "blocked": false,
  "can_buy": true,
  "presets_cents": [
    2500,
    5000,
    10000,
    25000
  ],
  "min_cents": 1000,
  "max_cents": 100000,
  "card_fee": {
    "on": true,
    "percent_micros": 29000,
    "fixed_cents": 30
  },
  "reload": {
    "enabled": false,
    "threshold_micros": 10000000,
    "target_micros": 50000000,
    "monthly_max_micros": 200000000,
    "reloaded_micros": 0,
    "failed_at": null,
    "error": null
  },
  "agent_rate_micros": 3.6,
  "model_markup_percent": 10,
  "gateway_markup_percent": 5,
  "upgrade_credit_micros": 10000000,
  "expires_days": 365
}
```

## Errors

A failed request answers with one of these statuses and a body like `{"error": {"code": "not_found", "message": "Repository not found."}}`. See [errors](/reference/api/#errors).

| Status | Code | When |
| --- | --- | --- |
| 401 | `unauthenticated` | A token is required, or the one sent is not valid. |
| 403 | `forbidden` | The token is valid but not allowed to do this, such as a member-only change or an agent token outside its repository. |
| 404 | `not_found` | It does not exist, or you cannot see it. |
| 422 | `invalid` | The input is not valid. `message` says which field and why. |
