Skip to content

Commit be99f5e

Browse files
Kludexalexmojaki
andauthored
docs(gateway): add section about "unable to calculate spend" (#3423)
Co-authored-by: Alex Hall <alex.mojaki@gmail.com>
1 parent 10402d5 commit be99f5e

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

docs/gateway.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,31 @@ Choose a name for your organization (or accept the default). You will automatica
5454
A default project will be created for you. You can choose to use it, or create a new one on the [Projects](https://gateway.pydantic.dev/admin/projects) page.
5555

5656
### Add **Providers**
57+
5758
There are two ways to use Providers in the Pydantic AI Gateway: you can bring your own key (BYOK) or buy inference through the platform.
5859

5960
#### Bringing your own API key (BYOK)
6061

61-
On the [Providers](https://gateway.pydantic.dev/admin/providers) page, fill in the form to add a provider. Paste your API key into the form under Credentials, and make sure to **select the Project that will be associated to this provider**. It is possible to add multiple keys from the same provider.
62+
On the [Providers](https://gateway.pydantic.dev/admin/providers) page, fill in the form to add a provider.
63+
Paste your API key into the form under Credentials, and make sure to **select the Project that will be associated to this provider**.
64+
It is possible to add multiple keys from the same provider.
6265

6366
#### Use Built-in Providers
64-
Go to the Billing page, add a payment method, and purchase $15 in credits to activate built-in providers. This gives you single-key access to all available models from OpenAI, Anthropic, Google Vertex, AWS Bedrock, and Groq.
67+
68+
Go to the [Billing page](https://gateway.pydantic.dev/admin/billing), add a payment method, and purchase $15 in credits to activate built-in providers.
69+
This gives you single-key access to all available models from OpenAI, Anthropic, Google Vertex, AWS Bedrock, and Groq.
6570

6671
### Grant access to your team
72+
6773
On the [Users](https://gateway.pydantic.dev/admin/users) page, create an invitation and share the URL with your team to allow them to access the project.
6874

6975
### Create Gateway project keys
70-
On the Keys page, Admins can create project keys which are not affected by spending limits. Users can only create personal keys, that will inherit spending caps from both User and Project levels, whichever is more restrictive.
76+
77+
On the Keys page, Admins can create project keys which are not affected by spending limits.
78+
Users can only create personal keys, that will inherit spending caps from both User and Project levels, whichever is more restrictive.
7179

7280
## Usage
81+
7382
After setting up your account with the instructions above, you will be able to make an AI model request with the Pydantic AI Gateway.
7483
The code snippets below show how you can use PAIG with different frameworks and SDKs.
7584
You can add `gateway/` as prefix on every known provider that
@@ -87,6 +96,7 @@ Examples of providers and models that can be used are:
8796
| AWS Bedrock | `bedrock` | `gateway/bedrock:amazon.nova-micro-v1:0` |
8897

8998
### Pydantic AI
99+
90100
Before you start, make sure you are on version 1.16 or later of `pydantic-ai`. To update to the latest version run:
91101

92102
=== "uv"
@@ -123,6 +133,7 @@ The first known use of "hello, world" was in a 1974 textbook about the C program
123133

124134

125135
### Claude Code
136+
126137
Before you start, log out of Claude Code using `/logout`.
127138

128139
Set your gateway credentials as environment variables:
@@ -174,3 +185,16 @@ response = client.messages.create(
174185
print(response.content[0].text)
175186
#> Hello user
176187
```
188+
189+
## Troubleshooting
190+
191+
### Unable to calculate spend
192+
193+
The gateway needs to know the cost of the request in order to provide insights about the spend, and to enforce spending limits.
194+
If it's unable to calculate the cost, it will return a 400 error with the message "Unable to calculate spend".
195+
196+
When [configuring a provider](https://gateway.pydantic.dev/admin/providers/new), you need to decide if you want the gateway to block
197+
the API key if it's unable to calculate the cost. If you choose to block the API key, any further requests using that API key will fail.
198+
199+
We are actively working on supporting more providers, and models.
200+
If you have a specific provider that you would like to see supported, please let us know on [Slack](https://logfire.pydantic.dev/docs/join-slack/) or [open an issue on `genai-prices`](https://github.com/pydantic/genai-prices/issues/new).

0 commit comments

Comments
 (0)