Skip to content

fix (provider/gateway): image/video error handler#12506

Merged
mclenhard merged 7 commits intovercel:mainfrom
mclenhard:fix-gateway-examples-and-image-error-handler
Feb 13, 2026
Merged

fix (provider/gateway): image/video error handler#12506
mclenhard merged 7 commits intovercel:mainfrom
mclenhard:fix-gateway-examples-and-image-error-handler

Conversation

@mclenhard
Copy link
Copy Markdown
Contributor

@mclenhard mclenhard commented Feb 12, 2026

Add Gateway Timeout Error Handling Examples

Background

Proper error handling for timeout scenarios is crucial for applications using the AI Gateway. This PR improves the error handling for timeout situations and adds examples demonstrating how these errors are handled.

Summary

  • Fixed error handling in Gateway models by making asGatewayError async in both image and video model implementations
  • Added three new examples demonstrating timeout error handling for:
    • Image generation (generate-image/gateway-timeout.ts)
    • Video generation (generate-video/gateway-timeout.ts)
    • Text streaming (stream-text/gateway-timeout.ts)

Each example uses undici with an extremely short timeout (1ms) to deliberately trigger timeout errors, showing how the Gateway SDK catches and provides helpful error messages with troubleshooting guidance.

Manual Verification

Tested each example by running them with the AI Gateway API key set. Confirmed that they properly trigger timeout errors and display the expected error information including the original error cause.

Checklist

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

@mclenhard mclenhard requested a review from shaper February 12, 2026 22:54
@mclenhard mclenhard changed the title Fix gateway examples and image error handler fix (provider/gateway): image/video error handler Feb 12, 2026
@mclenhard mclenhard merged commit e858654 into vercel:main Feb 13, 2026
19 checks passed
gr2m pushed a commit that referenced this pull request Feb 16, 2026
# Add Gateway Timeout Error Handling Examples

## Background

Proper error handling for timeout scenarios is crucial for applications
using the AI Gateway. This PR improves the error handling for timeout
situations and adds examples demonstrating how these errors are handled.

## Summary

- Fixed error handling in Gateway models by making `asGatewayError`
async in both image and video model implementations
- Added three new examples demonstrating timeout error handling for:
  - Image generation (`generate-image/gateway-timeout.ts`)
  - Video generation (`generate-video/gateway-timeout.ts`) 
  - Text streaming (`stream-text/gateway-timeout.ts`)

Each example uses undici with an extremely short timeout (1ms) to
deliberately trigger timeout errors, showing how the Gateway SDK catches
and provides helpful error messages with troubleshooting guidance.

## Manual Verification

Tested each example by running them with the AI Gateway API key set.
Confirmed that they properly trigger timeout errors and display the
expected error information including the original error cause.

## Checklist

- [ ] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [ ] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [ ] I have reviewed this pull request (self-review)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants