Skip to content

Commit 623bab4

Browse files
authored
[AI Gateway]: Add unified billing docs (#24728)
* [AI Gateway]: Add unified billing docs * fix: typo, add spend limit docs
1 parent b31d6eb commit 623bab4

File tree

5 files changed

+81
-11
lines changed

5 files changed

+81
-11
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
---
3+
pcx_content_type: configuration
4+
title: Unified Billing
5+
sidebar:
6+
order: 1
7+
head: []
8+
description: Use the Cloudflare billing to pay for and authenticate your inference requests.
9+
---
10+
11+
:::caution
12+
Unified Billing is in closed beta. Request for access.
13+
:::
14+
15+
Unified Billing allows users to connect to various AI providers (e.g. OpenAI, Anthropic) and receive a single Cloudflare bill. To use Unified Billing, users must purchase and load credits into their Cloudflare account, via the Dashboard, which can then be spent via the AI Gateway.
16+
17+
18+
### Load credits
19+
20+
- Navigate to [AI Gateway](https://dash.cloudflare.com/?to=/:account/ai/ai-gateway) on Cloudflare dashboard
21+
- The "Credits Available" card on the top right shows how many AI gateway credits you have on your account currently.
22+
- Click "Manage" to navigate to the new billing page
23+
- If you don't have a payment method already on your account, you will be prompted to "Add a payment method to purchase credits" on top of page.
24+
- Once you have a card added, you will be able to do a credit top up on your account by clicking "Top-up credits", and then adding the required amount on the next popup.
25+
26+
27+
### Auto-top up
28+
29+
- Navigate to [AI Gateway](https://dash.cloudflare.com/?to=/:account/ai/ai-gateway) on Cloudflare dashboard
30+
- Click "Manage" on the "Credits Available" card on the top right to navigate to the new billing page
31+
- Click the "Setup auto top-up credits" option on the dashboard, and set up a threshold and a recharge amount for auto topup.
32+
33+
When your balance falls below the given threshold, we will automatically apply the auto topup on your account.
34+
35+
### Using Unified Billing
36+
37+
#### Pre-requisites
38+
39+
- Ensure your gateway is [authenticated](/ai-gateway/configuration/authentication/).
40+
41+
Call any supported provider without passing any API Key. The request will automatically use Cloudflare's key and deduct credits from your account.
42+
43+
Example with Unified API:
44+
45+
```bash
46+
curl -X POST https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/compat/chat/completions \
47+
--header 'cf-aig-authorization: Bearer {CLOUDFLARE_TOKEN}' \
48+
--header 'Content-Type: application/json' \
49+
--data '{
50+
"model": "google-ai-studio/gemini-2.5-pro",
51+
"messages": [
52+
{
53+
"role": "user",
54+
"content": "What is Cloudflare?"
55+
}
56+
]
57+
}'
58+
```
59+
60+
### Spend limit
61+
62+
Set spend limits to prevent unexpected charges on your loaded credits. You can define daily, weekly, or monthly limits. When a limit is reached, the AI Gateway automatically stops processing requests until the period resets or you increase the limit.
63+
64+
65+
### Supported Providers
66+
67+
- [OpenAI](/ai-gateway/usage/providers/openai/)
68+
- [Anthropic](/ai-gateway/usage/providers/anthropic/)
69+
- [Google AI Studio](/ai-gateway/usage/providers/google-ai-studio/)
70+
- [xAI](/ai-gateway/usage/providers/grok/)
71+
- [Groq](/ai-gateway/usage/providers/groq/)

src/content/docs/ai-gateway/get-started.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ When you enable authentication on gateway each request is required to include a
2828

2929
Authenticate with your upstream provider using one of the following options:
3030

31+
- **Unified Billing:** Use the AI Gateway billing to pay for and authenticate your inference requests. Refer to [Unified Billing](/ai-gateway/features/unified-billing/).
3132
- **BYOK (Store Keys):** Store your credentials in Cloudflare, and AI Gateway will include them at runtime. Refer to [BYOK](/ai-gateway/configuration/bring-your-own-keys/).
3233
- **Request headers:** Include your provider key in the request headers as you normally would (for example, `Authorization: Bearer <PROVIDER_API_KEY>`).
3334

src/content/docs/ai-gateway/usage/providers/cerebras.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Render } from "~/components";
1010
## Endpoint
1111

1212
```txt
13-
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/cerebras-ai
13+
https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/cerebras
1414
```
1515

1616
## Prerequisites

src/content/docs/ai-gateway/usage/providers/grok.mdx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
---
2-
title: Grok
2+
title: xAI
33
pcx_content_type: get-started
44
---
55

66
import { Render } from "~/components";
77

8-
[Grok](https://docs.x.ai/docs#getting-started) is a general purpose model that can be used for a variety of tasks, including generating and understanding text, code, and function calling.
9-
108
## Endpoint
119

1210
```txt
@@ -23,8 +21,8 @@ When making requests to Grok, ensure you have the following:
2321

2422
- Your AI Gateway Account ID.
2523
- Your AI Gateway gateway name.
26-
- An active Grok API token.
27-
- The name of the Grok model you want to use.
24+
- An active xAI API token.
25+
- The name of the xAI model you want to use.
2826

2927
## Examples
3028

@@ -33,9 +31,9 @@ When making requests to Grok, ensure you have the following:
3331
```bash title="Request"
3432
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/grok/v1/chat/completions \
3533
--header 'content-type: application/json' \
36-
--header 'Authorization: Bearer {grok_api_token}' \
34+
--header 'Authorization: Bearer {xai_api_token}' \
3735
--data '{
38-
"model": "grok-beta",
36+
"model": "grok-4",
3937
"messages": [
4038
{
4139
"role": "user",
@@ -59,7 +57,7 @@ const openai = new OpenAI({
5957
});
6058

6159
const completion = await openai.chat.completions.create({
62-
model: "grok-beta",
60+
model: "grok-4",
6361
messages: [
6462
{
6563
role: "system",
@@ -91,7 +89,7 @@ client = OpenAI(
9189
)
9290

9391
completion = client.chat.completions.create(
94-
model="grok-beta",
92+
model="grok-4",
9593
messages=[
9694
{"role": "system", "content": "You are Grok, a chatbot inspired by the Hitchhiker's Guide to the Galaxy."},
9795
{"role": "user", "content": "What is the meaning of life, the universe, and everything?"},

src/content/docs/ai-gateway/usage/providers/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
pcx_content_type: navigation
3-
title: Provider specific
3+
title: Provider Native
44
sidebar:
55
group:
66
hideIndex: true

0 commit comments

Comments
 (0)