Skip to content

Commit 08562c9

Browse files
Backport: docs(example): set anthropic-beta header for anthropic streamObject() (#8916)
This is an automated backport of #8914 to the release-v5.0 branch. Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
1 parent 63d5f66 commit 08562c9

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

examples/ai-core/src/stream-object/anthropic.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { anthropic } from '@ai-sdk/anthropic';
22
import { streamObject } from 'ai';
3-
import 'dotenv/config';
43
import { z } from 'zod';
54

6-
async function main() {
5+
import { run } from '../lib/run';
6+
7+
run(async () => {
78
const result = streamObject({
89
model: anthropic('claude-sonnet-4-20250514'),
910
maxOutputTokens: 5000,
@@ -20,16 +21,13 @@ async function main() {
2021
}),
2122
prompt:
2223
'Generate 3 character descriptions for a fantasy role playing game.',
23-
onError: err => {
24-
console.error(err);
24+
headers: {
25+
'anthropic-beta': 'fine-grained-tool-streaming-2025-05-14',
2526
},
26-
temperature: 0,
2727
});
2828

2929
for await (const partialObject of result.partialObjectStream) {
3030
console.clear();
3131
console.log(partialObject);
3232
}
33-
}
34-
35-
main().catch(console.error);
33+
});

0 commit comments

Comments
 (0)