Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
View categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Working with Node.js
      • Node.js Behavior in Heroku
      • Troubleshooting Node.js Apps
    • Ruby
      • Rails Support
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • PHP Behavior in Heroku
      • Working with PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Working with AI
    • Heroku Inference
      • Inference API
      • Quick Start Guides
      • AI Models
      • Inference Essentials
    • Vector Database
    • Model Context Protocol
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • AI
  • Heroku Inference
  • Inference API
  • Managed Inference and Agents API /v1/images/generations

Managed Inference and Agents API /v1/images/generations

Last updated May 13, 2025

Table of Contents

  • Request Body Parameters
  • Request Headers
  • Response Format
  • Example Request
  • Example Response

The /v1/images/generations endpoint generates images based on a descriptive text prompt. You can control the aspect ratio, image format, and even provide a seed for reproducibility. Optional parameters allow you to refine the output further, such as providing negative prompts to exclude specific elements.

Request Body Parameters

Use parameters to control details, such as the size and format of images you generate.

Required Parameters

Field Type Description Example
model string ID of the image generation model to use "stable-image-ultra"
prompt string text prompt describing the image to generate (max length of 10,000 characters) "A beautiful sunset over the mountains."

Optional Parameters

Field Type Description Default Example
aspect_ratio enum<string> controls the aspect ratio of the generated image
one of:"16:9", "1:1", "21:9", "2:3", "3:2", "4:5", "5:4", "9:16", or "9:21"
"1:1" "16:9"
negative_prompt string keywords or phrases to avoid in the image (for example, "crowded" will help prevent a crowded scene)
max length:10,000 characters
"" "crowded"
output_format enum<string> format of the output image
one of:"jpeg" or "png"
"png" "jpeg"
size enum<string> size, in pixels, of the output image
one of: "1344x768", "1024x1024", "1536x640", "832x1216", "1216x832", "896x1088", "1088x896", "768x1344", "640x1536"
"1024x1024" "640x1536"
seed number a starting value used as a base to generate the image from (if all parameters remain the same, images generated with the same seed will be identical, while images generated with different seeds will be similar, but not identical)
range: 0(random) to 4294967295
0 123

Request Headers

In the following example, we assume your model resource has an alias of "DIFFUSION" (meaning you created the model resource with an --as DIFFUSION flag).

Header Type Description
Authorization string your AI add-on’s ‘DIFFUSION’ value (API bearer token)

All inference curl requests must include an Authorization header containing your Heroku Inference key for the specified model.

Response Format

When a request is successful, the API returns a JSON object with the following structure:

Field Type Description
created integer unix timestamp of when image was created
data array of objects list of generated images (always length of 1)

Data Object

Each object inside the data array includes:

Field Type Description
b64_json string (optional) generated image, encoded in base64
revised_prompt string included for compatibility with OpenAI-style responses
always: ""

Example Request

Let’s walk through an example /v1/images/generations curl request.

First, use this command to set your Heroku environment variables as local variables.

eval $(heroku config -a $APP_NAME --shell | grep '^DIFFUSION_' | sed 's/^/export /' | tee >(cat >&2))

Next, send the curl request:

curl $DIFFUSION_URL/v1/images/generations \
 -H "Authorization: Bearer $DIFFUSION_KEY" \
 -d @- <<EOF
{
  "model": "$DIFFUSION_MODEL_ID",
  "prompt": "A surreal landscape with glowing mushrooms under a night sky."
}
EOF

Here’s the same request, altered to parse the base64 and open the image on your computer:

curl $DIFFUSION_URL/v1/images/generations \
 -H "Authorization: Bearer $DIFFUSION_KEY" \
 -d @- <<EOF | jq -r '.data[0].b64_json' | base64 --decode > "x.png"
{
  "model": "$DIFFUSION_MODEL_ID",
  "prompt": "A surreal landscape with glowing mushrooms under a night sky."
}
EOF

open x.png

Example Response

{
  "created": 1745612037,
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
      "revised_prompt": ""
    }
  ]
}

Keep reading

  • Inference API

Feedback

Log in to submit feedback.

Managed Inference and Agents API /v1/mcp/servers Managed Inference and Agents API /v1/mcp/servers

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices