Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AI gateway] Request timeouts for fallback providers #19391

Open
wants to merge 3 commits into
base: production
Choose a base branch
from

Conversation

kodster28
Copy link
Contributor

Summary

New feature, request timeouts for fallback providers.

Updated several pages in AI gateway docs + changelog entry.

Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 total issue(s) found.

src/content/docs/ai-gateway/providers/universal.mdx Outdated Show resolved Hide resolved
You can use the Universal endpoint to contact every provider. The payload is expecting an array of message, and each message is an object with the following parameters:

- `provider` : the name of the provider you would like to direct this message to. Can be OpenAI, workers-ai, or any of our supported providers.
- `endpoint`: the pathname of the provider API you’re trying to reach. For example, on OpenAI it can be `chat/completions`, and for Workers AI this might be [`@cf/meta/llama-3.1-8b-instruct`](/workers-ai/models/llama-3.1-8b-instruct/). See more in the sections that are specific to [each provider](/ai-gateway/providers/).
- `authorization`: the content of the Authorization HTTP Header that should be used when contacting this provider. This usually starts with “Token” or “Bearer”.
- `headers`:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kathayl, I think this is accurate, but fact check me here :)

- `query`: the payload as the provider expects it in their official API.

## cURL example

The following example shows a simple setup with a primary model and a [fallback](/ai-gateway/configuration/fallbacks/) option.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanted to add more cross-links over to fallbacks page

@@ -41,6 +41,10 @@ entries:
general_definition: |-
Header to [bypass caching for a specific request](/ai-gateway/configuration/caching/#skip-cache-cf-aig-skip-cache).
- term: cf-aig-request-timeout
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds automatically to headers glossary page


If that fails, then the gateway will timeout and move to the fallback `@cf/meta/llama-3.1-8b-instruct-fast` model. This model has 3000 milliseconds - determined by the request-level `cf-aig-request-timeout` value - to complete the request and provide an answer.

```bash title="Request" collapse={36-50} {2,11,13-15}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the collapsible bit here is distracting, happy to remove.

Also, switched the example a bit so it made sense to me... but I also could just be hallucinating stuff. Happy to flip it back to the original.

kodster28 and others added 2 commits January 23, 2025 13:50
Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>
@github-actions github-actions bot added product:ai-gateway AI Gateway: https://developers.cloudflare.com/ai-gateway/ size/m labels Jan 23, 2025
Copy link

Deploying cloudflare-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 771fedb
Status: ✅  Deploy successful!
Preview URL: https://1647671e.cloudflare-docs-7ou.pages.dev
Branch Preview URL: https://aig-request-timeout.cloudflare-docs-7ou.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product:ai-gateway AI Gateway: https://developers.cloudflare.com/ai-gateway/ size/m
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants