import OpenAI from'openai'asyncfunctionmain(){const openai =newOpenAI({ apiKey:"<YOUR_OPENAI_API_KEY>"})const image =await openai.images.generate({ model:'dall-e-2', prompt:'A futuristic bridge connecting two digital worlds, with a sleek mint-colored pathway'});console.log(image.data[0].url)// the url to the newly created image}main();
The resulting image looks like this:
2
Register Image Design on Story
const response =awaitfetch("https://staging.crossmint.com/api/v1/ip/collections/{collectionId}/ipassets",{ method:"POST", headers:{"X-API-KEY":"<YOUR_API_KEY>","Content-Type":"application/json"}, body:JSON.stringify({ owner:'email:creator@example.com:story-testnet', nftMetadata:{ name:'My Image Design', description:'An image designed to represent a futuristic bridge connecting two digital worlds, with a sleek mint-colored pathway', image:'<YOUR_IMAGE_URL>'}, ipAssetMetadata:{ title:'My Image Design', createdAt:'2025-02-11T11:13:00', ipType:'image', creators:[{ name:'John Doe', email:'user@example.com', crossmintUserLocator:'email:user@example.com:story-testnet', contributionPercent:100},], attributes:[{ key:'Model', value:'dall-e-2'},{ key:'Prompt', value:'A futuristic bridge connecting two digital worlds, with a sleek mint-colored pathway'},]}})});const ipAsset =await response.json();console.log("IP Asset:", ipAsset);