Skip to content

Commit 53405c2

Browse files
authored
Create 2025-02-05-aig-request-handling.mdx
added copy
1 parent f197420 commit 53405c2

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: Request timeouts and Request retries with AI Gateway
3+
description: AI Gateway has added additional request handing, with request timeouts and request retries
4+
products:
5+
- ai-gateway
6+
date: 2025-02-05T11:00:00Z
7+
---
8+
9+
AI Gateway adds additional ways to handle requests - [Request Timeouts](/ai-gateway/configuration/request-handling/#request-timeouts) and [Request Retries](/ai-gateway/configuration/request-handling/#request-retries). This helps allowing you to manage AI interactions effectively and ensure your applications remain responsive and reliable.
10+
11+
These can be used on both the [Universal Endpoint](/ai-gateway/providers/universal) or directly to a [supported provider](/ai-gateway/providers/).
12+
13+
**Request timeouts**
14+
- A [request timeout](/ai-gateway/configuration/request-handling/#request-timeouts) allows you to trigger [fallbacks](/ai-gateway/configuration/fallbacks/) or a retry if a provider takes too long to respond.
15+
16+
To set a request timeout directly to a provider, add a `cf-aig-request-timeout` header.
17+
18+
```bash title="Provider-specific endpoint example" {4}
19+
curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/workers-ai/@cf/meta/llama-3.1-8b-instruct \
20+
--header 'Authorization: Bearer {cf_api_token}' \
21+
--header 'Content-Type: application/json' \
22+
--header 'cf-aig-request-timeout: 5000'
23+
--data '{"prompt": "What is Cloudflare?"}'
24+
```
25+
**Request retries**
26+
- A [request retry](/ai-gateway/configuration/request-handling/#request-retries) automatically retries failed requests, so you can recover from temporary issues without manual intervention.
27+
28+
To set up request retries directly to a provider, add the following headers:
29+
- cf-aig-max-attempts (number)
30+
- cf-aig-retry-delay (number)
31+
- cf-aig-backoff ("constant" | "linear" | "exponential)

0 commit comments

Comments
 (0)