Skip to content

fix(gateway): add caching provider option#15857

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

fix(gateway): add caching provider option#15857
pranjalbhatia710 wants to merge 1 commit into
vercel:mainfrom
pranjalbhatia710:pranjal/gateway-caching-provider-option

Conversation

@pranjalbhatia710

Copy link
Copy Markdown

Fixes #14595

Summary

  • Add caching: 'auto' to the AI Gateway provider options schema
  • Add a type-level check that GatewayProviderOptions accepts the caching option
  • Document the caching option in the AI Gateway provider options docs
  • Add a changeset for @ai-sdk/gateway

Tests

  • pnpm --filter @ai-sdk/gateway type-check
  • pnpm --filter @ai-sdk/gateway test:node -- src/gateway-provider.test.ts src/gateway-provider.test-d.ts
  • git diff --check origin/main..HEAD

@pranjalbhatia710
pranjalbhatia710 force-pushed the pranjal/gateway-caching-provider-option branch from 2ff5574 to ee69daa Compare June 17, 2026 12:16
@pranjalbhatia710

Copy link
Copy Markdown
Author

Rebased on latest main and resolved the conflict from the Gateway provider-options refactor.

The branch is now narrower: main already has the GatewayProviderOptions.caching?: 'auto' type, so this update keeps the docs, type-level usage coverage, and changeset for the caching option.

Validated locally:

git diff --check origin/main...HEAD
corepack pnpm install --frozen-lockfile
corepack pnpm --filter @ai-sdk/gateway type-check
corepack pnpm --filter @ai-sdk/gateway test:node

test:node passed: 19 files / 466 tests.

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