Small example for generating images using openai toolset document body style height 300pt ref https platform openai com docs api reference images create curl https api openai com v1 images generations H Content Type application json H Authorization Bearer OPENAI_API_KEY d prompt A cute baby sea otter n 2 size 1024x1024 useful curl converter https curlconverter com javascript const OPENAI_API_KEY sk xxxxxxxxxxxxxxxx const response await fetch https api openai com v1 images generations method POST headers Content Type application json Authorization Bearer OPENAI_API_KEY body JSON stringify prompt A cute baby frog with blue eyes riding a bike n 4 size 256x256 const jsonResponse await response json console log jsonResponse let img document createElement img document body appendChild img img src jsonResponse data 0 url for let n 0 n jsonResponse data length n let imgn document createElement img document body appendChild imgn imgn width 50 imgn height 50 imgn src jsonResponse data n url
ers Content Type application json Authorization Bearer OPENAI_API_KEY body JSON stringify prompt A cute baby frog with blue eyes riding a bike n 4 size 256x256 const jsonResponse await response json console log jsonResponse let img document createElement img document body appendChild img img src jsonResponse data 0 url for let n 0 n jsonResponse data length n let imgn document createElement img document body appendChild imgn imgn width 50 imgn height 50 imgn src jsonResponse data n url