# phi.quota

Read credit usage and its history.

## phi.quota.get

```python
phi.quota.get()
```

Returns `Quota`.

### Quota fields and schema

```json
{
  "type": "object",
  "required": [
    "organization_id",
    "credits_limit",
    "credits_reserved",
    "credits_consumed",
    "credits_available",
    "period_start",
    "period_end"
  ],
  "properties": {
    "credits": {
      "default": null,
      "anyOf": [
        {
          "$ref": "#/$defs/Credits"
        },
        {
          "type": "null"
        }
      ]
    },
    "credits_available": {
      "type": "integer"
    },
    "credits_consumed": {
      "type": "integer"
    },
    "credits_limit": {
      "type": "integer"
    },
    "credits_reserved": {
      "type": "integer"
    },
    "organization_id": {
      "type": "string"
    },
    "period_end": {
      "type": "string",
      "format": "date-time"
    },
    "period_start": {
      "type": "string",
      "format": "date-time"
    },
    "plan": {
      "default": null,
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "plan_source": {
      "default": null,
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "purchased_balance": {
      "type": "integer",
      "default": 0
    },
    "total_available": {
      "default": null,
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "$defs": {
    "AutoReloadSummary": {
      "type": "object",
      "required": [
        "enabled",
        "threshold_credits",
        "amount_cents"
      ],
      "properties": {
        "amount_cents": {
          "type": "integer"
        },
        "enabled": {
          "type": "boolean"
        },
        "threshold_credits": {
          "type": "integer"
        }
      }
    },
    "Credits": {
      "type": "object",
      "required": [
        "allowance",
        "allowance_available",
        "purchased",
        "total_available",
        "auto_reload"
      ],
      "properties": {
        "allowance": {
          "type": "integer"
        },
        "allowance_available": {
          "type": "integer"
        },
        "auto_reload": {
          "$ref": "#/$defs/AutoReloadSummary"
        },
        "purchased": {
          "type": "integer"
        },
        "reset_at": {
          "default": null,
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ]
        },
        "total_available": {
          "type": "integer"
        }
      }
    }
  }
}
```

## phi.quota.history

```python
phi.quota.history()
```

Returns `CursorList[LedgerEntry]`.

| Parameter | Type | Default | Required |
|---|---|---|---|
| `page` | `int` | `1` | Optional |
| `page_size` | `int` | `50` | Optional |
| `cursor` | `str \| None` | `None` | Optional |
| `reason` | `list[str] \| None` | `None` | Optional |

### LedgerEntry fields and schema

```json
{
  "type": "object",
  "required": [
    "id",
    "amount",
    "balance_after",
    "reason",
    "created_at"
  ],
  "properties": {
    "amount": {
      "type": "integer"
    },
    "balance_after": {
      "type": "integer"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "id": {
      "type": "string"
    },
    "note": {
      "default": null,
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "pipeline_type": {
      "default": null,
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "pool": {
      "default": null,
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "reason": {
      "type": "string"
    },
    "run_id": {
      "default": null,
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ]
    },
    "run_name": {
      "default": null,
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    }
  }
}
```

## phi.quota.iter

```python
phi.quota.iter()
```

Returns `Iterator[LedgerEntry]`.

| Parameter | Type | Default | Required |
|---|---|---|---|
| `page_size` | `int` | `50` | Optional |

### LedgerEntry fields and schema

```json
{
  "type": "object",
  "required": [
    "id",
    "amount",
    "balance_after",
    "reason",
    "created_at"
  ],
  "properties": {
    "amount": {
      "type": "integer"
    },
    "balance_after": {
      "type": "integer"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "id": {
      "type": "string"
    },
    "note": {
      "default": null,
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "pipeline_type": {
      "default": null,
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "pool": {
      "default": null,
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "reason": {
      "type": "string"
    },
    "run_id": {
      "default": null,
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ]
    },
    "run_name": {
      "default": null,
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    }
  }
}
```

## phi.quota.months

The ledger by calendar month: what finished runs used, what was added, how many runs finished.

```python
phi.quota.months()
```

Returns `list[Month]`.

| Parameter | Type | Default | Required |
|---|---|---|---|
| `limit` | `int` | `24` | Optional |

### Month fields and schema

```json
{
  "type": "object",
  "description": "One calendar month of the ledger: what finished runs used, what was added, how many runs finished.",
  "required": [
    "month",
    "used",
    "added",
    "runs"
  ],
  "properties": {
    "added": {
      "type": "integer"
    },
    "month": {
      "type": "string"
    },
    "runs": {
      "type": "integer"
    },
    "used": {
      "type": "integer"
    }
  }
}
```


---
Source: https://dynophi.com/docs/sdk/quota. From the installed client, phi 0.4.2, 2026-11-23.
