Skip to content

fix(gateway): add automatic caching provider option#15298

Closed
MukundaKatta wants to merge 1 commit into
vercel:mainfrom
MukundaKatta:codex/gateway-caching-provider-option
Closed

fix(gateway): add automatic caching provider option#15298
MukundaKatta wants to merge 1 commit into
vercel:mainfrom
MukundaKatta:codex/gateway-caching-provider-option

Conversation

@MukundaKatta

Copy link
Copy Markdown

Background

GatewayProviderOptions did not include the documented caching: 'auto' option, so strict TypeScript usage with satisfies GatewayProviderOptions failed.

Summary

  • Adds caching: 'auto' to GatewayProviderOptions
  • Adds a type-level test covering the accepted caching mode
  • Updates the AI Gateway provider options docs
  • Adds a patch changeset for @ai-sdk/gateway

Manual Verification

  • pnpm --filter @ai-sdk/gateway type-check
  • pnpm --filter @ai-sdk/gateway test:node -- gateway-language-model.test.ts

Note: both commands print the local Node v26 engine warning, but pass.

Checklist

  • 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)
  • 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)

Related Issues

Fixes #14595

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GatewayProviderOptions type missing 'caching' property (docs mismatch)

2 participants