Portkey supports the OpenAI signature to make text-to-image requests.
Copy
Ask AI
import Portkey from 'portkey-ai';// Initialize the Portkey clientconst portkey = new Portkey({ apiKey: "PORTKEY_API_KEY", // Replace with your Portkey API key virtualKey: "VIRTUAL_KEY" // Add your provider's virtual key});async function main() { const image = await portkey.images.generate({ model: "dall-e-3", prompt: "Lucy in the sky with diamonds" }); console.log(image.data);}main();
Create ImageOn completion, the request will get logged in the logs UI where the image can be viewed.(Note that providers may remove the hosted image after a period of time, so some logs might only contain the url)