Skip to main content
The most common use case is that of text-to-image where the user sends a prompt which the image model processes and returns an image.
The guide for vision models is available here.

Text-to-Image Usage

Portkey supports the OpenAI signature to make text-to-image requests.
import Portkey from 'portkey-ai';

// Initialize the Portkey client
const portkey = new Portkey({
    apiKey: "PORTKEY_API_KEY",  // Replace with your Portkey API key
    provider:"@PROVIDER"   
});

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();

API Reference

Create Image

OpenAI gpt-image-1 Parameters

For OpenAI’s gpt-image-1 model, additional parameters are supported:
ParameterTypeDescription
moderationstringContent moderation level for generated images
output_formatstringOutput format for the generated image
output_compressionnumberCompression level (0-100) for the output image
backgroundstringBackground style for the generated image
partial_imagesnumberNumber of partial images to return (0-3)
streambooleanWhether to stream partial image results
On 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)

Cookbook

Here’s a detailed cookbook on image generation using Portkey which demonstrates the use of multiple providers and routing between them through Configs.
Last modified on February 3, 2026