Skip to content

Commit 20c99fd

Browse files
committed
add structured outputs to example script
1 parent f877ef8 commit 20c99fd

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

scripts/fat-sdk-openrouter-example.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import { createOpenAICompatible } from '@ai-sdk/openai-compatible'
22
import { websiteUrl } from '@codebuff/npm-app/config'
3-
import { generateText } from 'ai'
3+
import { generateObject } from 'ai'
4+
import z from 'zod/v4'
45

56
const codebuffBackendProvider = createOpenAICompatible({
67
name: 'codebuff',
78
apiKey: '12345',
89
baseURL: websiteUrl + '/api/v1',
10+
// apiKey: process.env.OPEN_ROUTER_API_KEY,
11+
// baseURL: 'https://openrouter.ai/api/v1',
12+
supportsStructuredOutputs: true,
913
})
1014

11-
// const response = await streamText({
12-
const response = await generateText({
13-
model: codebuffBackendProvider('anthropic/claude-sonnet-4.5'),
15+
const response = await generateObject({
16+
schema: z.object({ greeting: z.string() }),
17+
// const response = await streamText({
18+
// const response = await generateText({
19+
model: codebuffBackendProvider('openai/gpt-5'),
1420
messages: [
1521
{
1622
role: 'user',

0 commit comments

Comments
 (0)