Skip to content
Merged
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
14 changes: 6 additions & 8 deletions examples/ai-core/src/stream-object/anthropic.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { anthropic } from '@ai-sdk/anthropic';
import { streamObject } from 'ai';
import 'dotenv/config';
import { z } from 'zod';

async function main() {
import { run } from '../lib/run';

run(async () => {
const result = streamObject({
model: anthropic('claude-sonnet-4-20250514'),
maxOutputTokens: 5000,
Expand All @@ -20,16 +21,13 @@ async function main() {
}),
prompt:
'Generate 3 character descriptions for a fantasy role playing game.',
onError: err => {
console.error(err);
headers: {
'anthropic-beta': 'fine-grained-tool-streaming-2025-05-14',
},
temperature: 0,
});

for await (const partialObject of result.partialObjectStream) {
console.clear();
console.log(partialObject);
}
}

main().catch(console.error);
});
Loading