add retries to openrouter generation endpoint to prevent failures on … #915
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
OpenRouter requests often fail NOT because the completion endpoint has failed but because it performs a follow call to the generation API for the usage stats which only waits for 500ms before the call. It then throws an error if the "generation" is unavailable which from a lot of providers takes more than 500ms after the completion is finished to be available on the endpoint. This adds some code to retry 3 times to make it more likely to succeed.
Type of change
How Has This Been Tested?
Tested with deepseek and google gemini models on openrouter.
Checklist:
Additional context
Related Issues
Reviewers
Important
Adds retry logic to OpenRouter generation endpoint in
openrouter.tsto improve reliability by retrying up to 3 times with a delay.openrouter.ts.This description was created by
for 9c480aa. It will automatically update as commits are pushed.