Skip to content

Commit c8a3892

Browse files
committed
feat (provider/openai): include more image generation response metadata
1 parent 9138be4 commit c8a3892

File tree

7 files changed

+483
-32
lines changed

7 files changed

+483
-32
lines changed

.changeset/heavy-suits-do.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@ai-sdk/openai': patch
3+
'ai': patch
4+
---
5+
6+
feat (provider/openai): include more image generation response metadata

examples/ai-core/src/generate-image/google-vertex.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'dotenv/config';
77
import { presentImages } from '../lib/present-image';
88

99
async function main() {
10-
const { image } = await generateImage({
10+
const result = await generateImage({
1111
model: vertex.image('imagen-3.0-generate-002'),
1212
prompt: 'A burrito launched through a tunnel',
1313
aspectRatio: '1:1',
@@ -18,7 +18,12 @@ async function main() {
1818
},
1919
});
2020

21-
await presentImages([image]);
21+
await presentImages(result.images);
22+
23+
console.log(
24+
'Provider metadata:',
25+
JSON.stringify(result.providerMetadata, null, 2),
26+
);
2227
}
2328

2429
main().catch(console.error);

examples/ai-core/src/generate-image/openai.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,19 @@ import { presentImages } from '../lib/present-image';
44
import 'dotenv/config';
55

66
async function main() {
7-
const prompt = 'Santa Claus driving a Cadillac';
7+
const prompt = 'A blue cream Persian cat in Kyoto in the style of ukiyo-e';
88
const result = await generateImage({
99
model: openai.image('gpt-image-1-mini'),
1010
prompt,
11-
});
12-
13-
// @ts-expect-error
14-
const revisedPrompt = result.providerMetadata.openai.images[0]?.revisedPrompt;
15-
16-
console.log({
17-
prompt,
18-
revisedPrompt,
19-
usage: result.usage,
11+
n: 3,
2012
});
2113

2214
await presentImages([result.image]);
15+
16+
console.log(
17+
'Provider metadata:',
18+
JSON.stringify(result.providerMetadata, null, 2),
19+
);
2320
}
2421

2522
main().catch(console.error);

0 commit comments

Comments
 (0)