Skip to content

Commit 5f439a1

Browse files
vercel-ai-sdk[bot]jerilynzhengclaude
authored
Backport: feat (provider/gateway): add hipaaCompliant provider option (#14128)
This is an automated backport of #13614 to the release-v6.0 branch. FYI @jerilynzheng Co-authored-by: Jerilyn Zheng <zheng.jerilyn@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ee90415 commit 5f439a1

File tree

5 files changed

+101
-0
lines changed

5 files changed

+101
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@ai-sdk/gateway': patch
3+
---
4+
5+
feat (provider/gateway): add hipaaCompliant gateway provider option

content/providers/01-ai-sdk-providers/00-ai-gateway.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,9 @@ The following gateway provider options are available:
786786

787787
Restricts routing requests to providers that have agreements with Vercel for AI Gateway to not use prompts for model training. If there are no providers available for the model that disallow prompt training, the request will fail. BYOK credentials are skipped when `disallowPromptTraining` is set to `true` to ensure that requests are only routed to providers that do not train on prompt data.
788788

789+
- **hipaaCompliant** _boolean_
790+
791+
Restricts routing to models and tools from providers that have signed a BAA with Vercel for the use of AI Gateway (requires Vercel HIPAA BAA add on). BYOK credentials are skipped when `hipaaCompliant` is set to `true` to ensure that requests are only routed to providers that support HIPAA compliance.
789792

790793
- **providerTimeouts** _object_
791794

@@ -876,6 +879,25 @@ const { text } = await generateText({
876879
});
877880
```
878881

882+
#### HIPAA Compliance Example
883+
884+
Set `hipaaCompliant` to true to route requests only to models or tools by providers that have signed a BAA with Vercel for the use of AI Gateway. If the model or tool does not have a HIPAA-compliant provider, the request will fail. When `hipaaCompliant` is `false` or not specified, there is no enforcement of restricting routing. BYOK credentials are skipped when `hipaaCompliant` is set to `true` to ensure that requests are only routed to providers that support HIPAA compliance.
885+
886+
```ts
887+
import type { GatewayProviderOptions } from '@ai-sdk/gateway';
888+
import { generateText } from 'ai';
889+
890+
const { text } = await generateText({
891+
model: 'anthropic/claude-sonnet-4.6',
892+
prompt: 'Analyze this patient data...',
893+
providerOptions: {
894+
gateway: {
895+
hipaaCompliant: true,
896+
} satisfies GatewayProviderOptions,
897+
},
898+
});
899+
```
900+
879901
### Provider-Specific Options
880902

881903
When using provider-specific options through AI Gateway, use the actual provider name (e.g. `anthropic`, `openai`, not `gateway`) as the key:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type { GatewayProviderOptions } from '@ai-sdk/gateway';
2+
import { streamText } from 'ai';
3+
import { run } from '../lib/run';
4+
5+
run(async () => {
6+
const result = streamText({
7+
model: 'openai/gpt-oss-120b',
8+
prompt: 'Tell me the history of the tenrec in a few sentences.',
9+
providerOptions: {
10+
gateway: {
11+
hipaaCompliant: true,
12+
} satisfies GatewayProviderOptions,
13+
},
14+
});
15+
16+
for await (const textPart of result.textStream) {
17+
process.stdout.write(textPart);
18+
}
19+
20+
console.log();
21+
console.log('Token usage:', await result.usage);
22+
console.log('Finish reason:', await result.finishReason);
23+
console.log(
24+
'Provider metadata:',
25+
JSON.stringify(await result.providerMetadata, null, 2),
26+
);
27+
});

packages/gateway/src/gateway-language-model.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,5 +1575,46 @@ describe('GatewayLanguageModel', () => {
15751575
gateway: { disallowPromptTraining: true },
15761576
});
15771577
});
1578+
1579+
it('should pass hipaaCompliant option', async () => {
1580+
prepareJsonResponse({
1581+
content: { type: 'text', text: 'Test response' },
1582+
});
1583+
1584+
await createTestModel().doGenerate({
1585+
prompt: TEST_PROMPT,
1586+
providerOptions: {
1587+
gateway: {
1588+
hipaaCompliant: true,
1589+
},
1590+
},
1591+
});
1592+
1593+
const requestBody = await server.calls[0].requestBodyJson;
1594+
expect(requestBody.providerOptions).toEqual({
1595+
gateway: { hipaaCompliant: true },
1596+
});
1597+
});
1598+
1599+
it('should pass both zeroDataRetention and hipaaCompliant options', async () => {
1600+
prepareJsonResponse({
1601+
content: { type: 'text', text: 'Test response' },
1602+
});
1603+
1604+
await createTestModel().doGenerate({
1605+
prompt: TEST_PROMPT,
1606+
providerOptions: {
1607+
gateway: {
1608+
zeroDataRetention: true,
1609+
hipaaCompliant: true,
1610+
},
1611+
},
1612+
});
1613+
1614+
const requestBody = await server.calls[0].requestBodyJson;
1615+
expect(requestBody.providerOptions).toEqual({
1616+
gateway: { zeroDataRetention: true, hipaaCompliant: true },
1617+
});
1618+
});
15781619
});
15791620
});

packages/gateway/src/gateway-provider-options.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ const gatewayProviderOptions = lazySchema(() =>
6565
* to not use prompts for model training will be used.
6666
*/
6767
disallowPromptTraining: z.boolean().optional(),
68+
/**
69+
* Whether to filter by only providers that are HIPAA compliant with
70+
* Vercel AI Gateway. When enabled, only providers that have agreements
71+
* with Vercel AI Gateway for HIPAA compliance will be used.
72+
*/
73+
hipaaCompliant: z.boolean().optional(),
6874
/**
6975
* Per-provider timeouts for BYOK credentials in milliseconds.
7076
* Controls how long to wait for a provider to start responding

0 commit comments

Comments
 (0)