Buy AI credit
Start buying AI credit.
/workspaces/{workspace}/ai_credit/checkoutReturns url, a payment page to open in a browser and pay by card; it comes back to the workspace’s billing page. amount_cents is the credit, in whole dollars from $10 (1000) to $1,000 (100000); any card fee is added on top. The credit is added once the payment goes through. Owners only, as a person: signed in or with a personal access token. A workspace’s own token and g1t’s agents never buy credit.
Open url in a browser to pay. Nothing is charged until the payment is made there; the credit then shows in get_ai_credit. An amount outside min_cents to max_cents, or not in whole dollars, is refused with invalid; a workspace that cannot buy credit (see can_buy) gets conflict or payment_required.
- Authentication: Required. Send an access token as
Authorization: Bearer. - MCP tool:
billingwithactionbuy_ai_credit, and the same inputs - Scope: An access token needs
billing:write.
Path parameters
Section titled “Path parameters”| Name | Type | Required | Description |
|---|---|---|---|
workspace |
string | Yes | The workspace’s slug, e.g. “flagon-io”. |
Body parameters
Section titled “Body parameters”Send a JSON object. Names are snake_case, as in responses; the camelCase spelling is accepted too.
| Name | Type | Required | Description |
|---|---|---|---|
amount_cents |
integer | Yes | The credit to buy, in cents, in whole dollars: 5000 is $50. |
Example request
Section titled “Example request”curl -X POST https://api.g1t.sh/workspaces/flagon-io/ai_credit/checkout \ -H "Authorization: Bearer $G1T_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "amount_cents": 5000 }'Example response
Section titled “Example response”A successful request answers 200 with:
{ "url": "https://checkout.example.com/c/pay/cs_test_a1b2c3"}Errors
Section titled “Errors”A failed request answers with one of these statuses and a body like {"error": {"code": "not_found", "message": "Repository not found."}}. See 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. |
| 409 | conflict |
The request conflicts with the current state. |
| 422 | invalid |
The input is not valid. message says which field and why. |