# phi.billing

Read credits and manage payments and auto-reload.

## phi.billing.auto_reload

Only an organization admin can use this.

```python
phi.billing.auto_reload(enabled=enabled, threshold_credits=threshold_credits, amount_cents=amount_cents, monthly_cap_cents=monthly_cap_cents)
```

Returns `AutoReload`.

| Parameter | Type | Required |
|---|---|---|
| `enabled` | `bool` | Required |
| `threshold_credits` | `int` | Required |
| `amount_cents` | `int` | Required |
| `monthly_cap_cents` | `int` | Required |

### AutoReload fields and schema

```json
{
  "type": "object",
  "required": [
    "enabled",
    "threshold_credits",
    "amount_cents",
    "monthly_cap_cents"
  ],
  "properties": {
    "amount_cents": {
      "type": "integer"
    },
    "disabled_reason": {
      "default": null,
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "enabled": {
      "type": "boolean"
    },
    "monthly_cap_cents": {
      "type": "integer"
    },
    "this_month_cents": {
      "type": "integer",
      "default": 0
    },
    "threshold_credits": {
      "type": "integer"
    }
  }
}
```

## phi.billing.get

```python
phi.billing.get()
```

Returns `Billing`.

### Billing fields and schema

```json
{
  "type": "object",
  "required": [
    "organization_id",
    "provider",
    "plan",
    "credit_price_cents",
    "balance",
    "auto_reload"
  ],
  "properties": {
    "auto_reload": {
      "$ref": "#/$defs/AutoReload"
    },
    "balance": {
      "$ref": "#/$defs/BillingBalance"
    },
    "credit_price_cents": {
      "type": "integer"
    },
    "organization_id": {
      "type": "string"
    },
    "packs": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CreditPack"
      }
    },
    "payment_method": {
      "default": null,
      "anyOf": [
        {
          "$ref": "#/$defs/PaymentMethod"
        },
        {
          "type": "null"
        }
      ]
    },
    "payment_method_saved": {
      "type": "boolean",
      "default": false
    },
    "plan": {
      "type": "string"
    },
    "portal_available": {
      "type": "boolean",
      "default": false
    },
    "presets": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/LoadPreset"
      }
    },
    "provider": {
      "type": "string"
    }
  },
  "$defs": {
    "AutoReload": {
      "type": "object",
      "required": [
        "enabled",
        "threshold_credits",
        "amount_cents",
        "monthly_cap_cents"
      ],
      "properties": {
        "amount_cents": {
          "type": "integer"
        },
        "disabled_reason": {
          "default": null,
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "enabled": {
          "type": "boolean"
        },
        "monthly_cap_cents": {
          "type": "integer"
        },
        "this_month_cents": {
          "type": "integer",
          "default": 0
        },
        "threshold_credits": {
          "type": "integer"
        }
      }
    },
    "BillingBalance": {
      "type": "object",
      "required": [
        "allowance",
        "allowance_available",
        "purchased",
        "total_available"
      ],
      "properties": {
        "allowance": {
          "type": "integer"
        },
        "allowance_available": {
          "type": "integer"
        },
        "purchased": {
          "type": "integer"
        },
        "reset_at": {
          "default": null,
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ]
        },
        "total_available": {
          "type": "integer"
        }
      }
    },
    "CreditPack": {
      "type": "object",
      "required": [
        "slug",
        "display_name",
        "credits",
        "amount_cents"
      ],
      "properties": {
        "amount_cents": {
          "type": "integer"
        },
        "credits": {
          "type": "integer"
        },
        "display_name": {
          "type": "string"
        },
        "slug": {
          "type": "string"
        }
      }
    },
    "PaymentMethod": {
      "type": "object",
      "required": [
        "brand",
        "last4",
        "exp_month",
        "exp_year"
      ],
      "properties": {
        "brand": {
          "type": "string"
        },
        "exp_month": {
          "type": "integer"
        },
        "exp_year": {
          "type": "integer"
        },
        "last4": {
          "type": "string"
        }
      }
    },
    "LoadPreset": {
      "type": "object",
      "required": [
        "amount_cents",
        "credits"
      ],
      "properties": {
        "amount_cents": {
          "type": "integer"
        },
        "credits": {
          "type": "integer"
        }
      }
    }
  }
}
```

## phi.billing.load

Start a load; the person pays at ``LoadStart.url`` and the credits

Only an organization admin can use this.

```python
phi.billing.load()
```

Returns `LoadStart`.

| Parameter | Type | Default | Required |
|---|---|---|---|
| `amount_cents` | `int \| None` | `None` | Optional |
| `pack` | `str \| None` | `None` | Optional |

### LoadStart fields and schema

```json
{
  "type": "object",
  "required": [
    "url",
    "load"
  ],
  "properties": {
    "load": {
      "$ref": "#/$defs/Load"
    },
    "url": {
      "type": "string"
    }
  },
  "$defs": {
    "Load": {
      "type": "object",
      "required": [
        "id",
        "kind",
        "amount_cents",
        "credits",
        "status",
        "created_at"
      ],
      "properties": {
        "amount_cents": {
          "type": "integer"
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "credits": {
          "type": "integer"
        },
        "error": {
          "default": null,
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "id": {
          "type": "string"
        },
        "kind": {
          "type": "string",
          "enum": [
            "load",
            "auto"
          ]
        },
        "provider_ref": {
          "default": null,
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "settled_at": {
          "default": null,
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "pending",
            "charged",
            "credited",
            "failed"
          ]
        }
      }
    }
  }
}
```

## phi.billing.loads

```python
phi.billing.loads()
```

Returns `list[Load]`.

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

### Load fields and schema

```json
{
  "type": "object",
  "required": [
    "id",
    "kind",
    "amount_cents",
    "credits",
    "status",
    "created_at"
  ],
  "properties": {
    "amount_cents": {
      "type": "integer"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "credits": {
      "type": "integer"
    },
    "error": {
      "default": null,
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "id": {
      "type": "string"
    },
    "kind": {
      "type": "string",
      "enum": [
        "load",
        "auto"
      ]
    },
    "provider_ref": {
      "default": null,
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "settled_at": {
      "default": null,
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "charged",
        "credited",
        "failed"
      ]
    }
  }
}
```

## phi.billing.portal

Only an organization admin can use this.

```python
phi.billing.portal()
```

Returns `str`.


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