|
| 1 | +import { JSONArray, JSONValue } from '../../json-value'; |
| 2 | +import { SharedV4Warning } from '../../shared/v4/shared-v4-warning'; |
| 3 | +import { ImageModelV4Usage } from './image-model-v4-usage'; |
| 4 | + |
| 5 | +export type ImageModelV4ProviderMetadata = Record< |
| 6 | + string, |
| 7 | + { |
| 8 | + images: JSONArray; |
| 9 | + } & JSONValue |
| 10 | +>; |
| 11 | + |
| 12 | +/** |
| 13 | + * The result of an image model doGenerate call. |
| 14 | + */ |
| 15 | +export type ImageModelV4Result = { |
| 16 | + /** |
| 17 | + * Generated images as base64 encoded strings or binary data. |
| 18 | + * The images should be returned without any unnecessary conversion. |
| 19 | + * If the API returns base64 encoded strings, the images should be returned |
| 20 | + * as base64 encoded strings. If the API returns binary data, the images should |
| 21 | + * be returned as binary data. |
| 22 | + */ |
| 23 | + images: Array<string> | Array<Uint8Array>; |
| 24 | + |
| 25 | + /** |
| 26 | + * Warnings for the call, e.g. unsupported features. |
| 27 | + */ |
| 28 | + warnings: Array<SharedV4Warning>; |
| 29 | + |
| 30 | + /** |
| 31 | + * Additional provider-specific metadata. They are passed through |
| 32 | + * from the provider to the AI SDK and enable provider-specific |
| 33 | + * results that can be fully encapsulated in the provider. |
| 34 | + * |
| 35 | + * The outer record is keyed by the provider name, and the inner |
| 36 | + * record is provider-specific metadata. It always includes an |
| 37 | + * `images` key with image-specific metadata |
| 38 | + * |
| 39 | + * ```ts |
| 40 | + * { |
| 41 | + * "openai": { |
| 42 | + * "images": ["revisedPrompt": "Revised prompt here."] |
| 43 | + * } |
| 44 | + * } |
| 45 | + * ``` |
| 46 | + */ |
| 47 | + providerMetadata?: ImageModelV4ProviderMetadata; |
| 48 | + |
| 49 | + /** |
| 50 | + * Response information for telemetry and debugging purposes. |
| 51 | + */ |
| 52 | + response: { |
| 53 | + /** |
| 54 | + * Timestamp for the start of the generated response. |
| 55 | + */ |
| 56 | + timestamp: Date; |
| 57 | + |
| 58 | + /** |
| 59 | + * The ID of the response model that was used to generate the response. |
| 60 | + */ |
| 61 | + modelId: string; |
| 62 | + |
| 63 | + /** |
| 64 | + * Response headers. |
| 65 | + */ |
| 66 | + headers: Record<string, string> | undefined; |
| 67 | + }; |
| 68 | + |
| 69 | + /** |
| 70 | + * Optional token usage for the image generation call (if the provider reports it). |
| 71 | + */ |
| 72 | + usage?: ImageModelV4Usage; |
| 73 | +}; |
0 commit comments