Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gateway-caching-provider-options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ai-sdk/gateway": patch
---

Add `caching: 'auto'` to Gateway provider options.
6 changes: 6 additions & 0 deletions content/providers/01-ai-sdk-providers/00-ai-gateway.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,12 @@ The following gateway provider options are available:

Example: `models: ['openai/gpt-5.4-nano', 'gemini-3-flash-preview']` will try the fallback models in order if the primary model fails.

- **caching** _'auto'_

Enables AI Gateway prompt caching for the request. Set `caching: 'auto'` to let AI Gateway automatically cache supported prompt content when possible.

Example: `caching: 'auto'` will enable automatic gateway caching for eligible requests.

- **user** _string_

Optional identifier for the end user on whose behalf the request is being made. This is used for spend tracking and attribution purposes, allowing you to track usage per end-user in your application.
Expand Down
7 changes: 7 additions & 0 deletions packages/gateway/src/gateway-provider.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { createGateway } from './gateway-provider';
import type { GatewayProviderOptions } from './gateway-provider-options';

createGateway({ apiKey: 'vck_test-key' });
createGateway({ apiKey: 'vca_test-token' });
createGateway({ apiKey: 'vca_test-token', teamIdOrSlug: 'vercel' });
createGateway({ teamIdOrSlug: 'vercel' });
createGateway({});

const gatewayProviderOptions = {
caching: 'auto',
} satisfies GatewayProviderOptions;

gatewayProviderOptions.caching satisfies 'auto';

// @ts-expect-error token is not a supported Gateway provider setting
createGateway({ token: 'vca_test-token' });