File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed
Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -167,13 +167,19 @@ Use the `ai.generateImage()` method to create AI-generated images based on text
167167``` jsx
168168const imageResponse = await cosmic .ai .generateImage ({
169169 prompt: ' A serene mountain landscape at sunset' ,
170+ // Optional parameters
170171 metadata: { tags: [' landscape' , ' mountains' , ' sunset' ] },
171172 folder: ' ai-generated-images' ,
172173 alt_text: ' A beautiful mountain landscape with a colorful sunset' ,
173174});
174175
175- console .log (imageResponse .image .url ); // Direct URL to the generated image
176- console .log (imageResponse .image .imgix_url ); // Imgix-enhanced URL for additional transformations
176+ // Access the generated image properties
177+ console .log (imageResponse .media .url ); // Direct URL to the generated image
178+ console .log (imageResponse .media .imgix_url ); // Imgix-enhanced URL for additional transformations
179+ console .log (imageResponse .media .width ); // Image width
180+ console .log (imageResponse .media .height ); // Image height
181+ console .log (imageResponse .media .alt_text ); // Alt text for the image
182+ console .log (imageResponse .revised_prompt ); // Potentially revised prompt used by the AI
177183```
178184
179185## Learn more
Original file line number Diff line number Diff line change @@ -30,13 +30,26 @@ export interface TextGenerationResponse {
3030}
3131
3232export interface ImageGenerationResponse {
33- image : {
33+ media : {
3434 id : string ;
35+ name : string ;
36+ original_name : string ;
37+ size : number ;
38+ type : string ;
39+ bucket : string ;
40+ created_at : string ;
41+ created_by : string | null ;
42+ modified_at : string ;
43+ modified_by : string | null ;
44+ width : number ;
45+ height : number ;
46+ alt_text ?: string ;
3547 url : string ;
3648 imgix_url : string ;
37- prompt : string ;
38- revised_prompt : string ;
49+ metadata ?: Record < string , any > ;
50+ folder ? : string | null ;
3951 } ;
52+ revised_prompt : string ;
4053}
4154
4255export const aiChainMethods = (
You can’t perform that action at this time.
0 commit comments