diff --git a/.changeset/gateway-caching-provider-options.md b/.changeset/gateway-caching-provider-options.md new file mode 100644 index 000000000000..fb49b6a2d2e3 --- /dev/null +++ b/.changeset/gateway-caching-provider-options.md @@ -0,0 +1,5 @@ +--- +"@ai-sdk/gateway": patch +--- + +Add `caching: 'auto'` to Gateway provider options. diff --git a/content/providers/01-ai-sdk-providers/00-ai-gateway.mdx b/content/providers/01-ai-sdk-providers/00-ai-gateway.mdx index 8c0607918c0a..074d58dc8fde 100644 --- a/content/providers/01-ai-sdk-providers/00-ai-gateway.mdx +++ b/content/providers/01-ai-sdk-providers/00-ai-gateway.mdx @@ -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. diff --git a/packages/gateway/src/gateway-provider.test-d.ts b/packages/gateway/src/gateway-provider.test-d.ts index 6a6374fef7a8..20b9a637e8d3 100644 --- a/packages/gateway/src/gateway-provider.test-d.ts +++ b/packages/gateway/src/gateway-provider.test-d.ts @@ -1,4 +1,5 @@ import { createGateway } from './gateway-provider'; +import type { GatewayProviderOptions } from './gateway-provider-options'; createGateway({ apiKey: 'vck_test-key' }); createGateway({ apiKey: 'vca_test-token' }); @@ -6,5 +7,11 @@ 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' });