Skip to content

fix(provider/gateway): add missing caching property to GatewayProviderOptions#14609

Closed
Zelys-DFKH wants to merge 2 commits into
vercel:mainfrom
Zelys-DFKH:fix/gateway-provider-options-caching
Closed

fix(provider/gateway): add missing caching property to GatewayProviderOptions#14609
Zelys-DFKH wants to merge 2 commits into
vercel:mainfrom
Zelys-DFKH:fix/gateway-provider-options-caching

Conversation

@Zelys-DFKH

Copy link
Copy Markdown

Background

GatewayProviderOptions was missing the caching field, so TypeScript raises an error when users set caching: 'auto' per the automatic caching docs.

Summary

  • Add caching: z.literal('auto').optional() to the gatewayProviderOptions schema
  • Document caching in the Gateway Provider Options reference section of content/providers/01-ai-sdk-providers/00-ai-gateway.mdx
  • Add examples/ai-functions/src/stream-text/gateway/auto-caching.ts
  • Add packages/gateway/src/gateway-provider-options.test-d.ts with type tests for the new field

Manual Verification

Run the new example:

cd examples/ai-functions
pnpm tsx src/stream-text/gateway/auto-caching.ts

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)

Fixes #14595

…rOptions

The GatewayProviderOptions type was missing the caching field despite it being
documented at https://vercel.com/docs/ai-gateway/models-and-providers/automatic-caching.
This caused a TypeScript error when users tried to set caching: 'auto' with
satisfies GatewayProviderOptions.

Fixes vercel#14595
@tigent tigent Bot added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented documentation Improvements or additions to documentation provider/gateway Issues related to the @ai-sdk/gateway provider labels Apr 17, 2026
gr2m pushed a commit that referenced this pull request Jun 29, 2026
…16483)

## Background

The `caching` provider option for the AI Gateway was previously untyped
despite being in AI Gateway docs.

#15768 added it, but only to v7

## Summary

Backported that change by updating the `gatewayProviderOptions` zod
schema in v6.

## Manual Verification

This is properly typed in v6 now with intellisense working and no
errors:

```typescript
  const result = streamText({
    model: 'anthropic/claude-sonnet-4.6',
    system:
      'You are a helpful assistant with access to a large knowledge base...',
    prompt: 'What is the capital of France?',
    providerOptions: {
        gateway: {
            caching: 'auto',
        } satisfies GatewayProviderOptions,
    },
  });
```

## Checklist

- [X] All commits are signed (PRs with unsigned commits cannot be
merged)
- [ ] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [X] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [X] I have reviewed this pull request (self-review)

## Related Issues

Fixed #14595

Closes #14609
Closes #14632
Closes #14664
Closes #14886
Closes #15298
Closes #15329
Closes #15458
Closes #15500
Closes #15857
@n1ckoates

Copy link
Copy Markdown
Member

Added to AI SDK 7 in #15768
Backported to AI SDK 6 in #16483

@n1ckoates n1ckoates closed this Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented documentation Improvements or additions to documentation provider/gateway Issues related to the @ai-sdk/gateway provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GatewayProviderOptions type missing 'caching' property (docs mismatch)

2 participants