Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/content/docs/ai-gateway/reference/troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ For troubleshooting Data Loss Prevention issues such as DLP not triggering or un

## Request failures

### Insufficient credits (`402`)

When a [Run request](/ai-gateway/usage/rest-api/) uses Unified Billing, exhausted credits return HTTP `402` with `internalCode: 2021` in the error response.

[Add credits](/ai-gateway/features/unified-billing/#load-credits) before retrying the request. Retrying without replenishing your balance does not resolve this error.

A background run can also fail because credits are exhausted. An initial `202` response confirms acceptance, not successful completion. If you configured a webhook, check the `state` and `error` fields in its [payload](/ai-gateway/usage/rest-api/#webhook-payload) for the final outcome.

### Requests timing out

- Check if the upstream provider is experiencing issues
Expand Down
4 changes: 3 additions & 1 deletion src/content/docs/ai-gateway/usage/rest-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ curl -X POST "https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_
}'
```

A background request returns immediately while the model runs. The result is delivered to your webhook when the run completes.
An accepted background request returns HTTP `202` while the model runs. This confirms acceptance, not successful completion. AI Gateway sends the final outcome to your webhook when the run finishes.

#### Webhook payload

Expand All @@ -172,6 +172,8 @@ When the run completes, AI Gateway sends a single `POST` request to your `webhoo
}
```

Check `state` to determine the final outcome. A value of `Completed` indicates success. A value of `Failed` indicates failure, and `error` contains the error message.

Webhook delivery is best-effort and is not retried. The destination must be an HTTPS URL that does not resolve to a private network address.

#### Webhook format
Expand Down
Loading