Skip to content

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

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

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

Conversation

@Genmin

@Genmin Genmin commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #14595

Summary

  • add caching: 'auto' to the Gateway provider options schema/exported type
  • add compile-time type coverage for GatewayProviderOptions
  • add node/edge request passthrough coverage for the gateway language model
  • document the option in the AI Gateway provider options list

Validation

  • corepack pnpm install --frozen-lockfile
  • corepack pnpm --filter @ai-sdk/provider --filter @ai-sdk/provider-utils --filter @ai-sdk/test-server build
  • corepack pnpm --filter @ai-sdk/gateway exec vitest --config vitest.node.config.js --run src/gateway-language-model.test.ts
  • corepack pnpm --filter @ai-sdk/gateway exec vitest --config vitest.edge.config.js --run src/gateway-language-model.test.ts
  • corepack pnpm --filter @ai-sdk/gateway type-check
  • corepack pnpm exec ultracite check packages/gateway/src/gateway-provider-options.ts packages/gateway/src/gateway-provider-options.test-d.ts packages/gateway/src/gateway-language-model.test.ts content/providers/01-ai-sdk-providers/00-ai-gateway.mdx
  • corepack pnpm --filter @ai-sdk/gateway build
  • git diff --check

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