Skip to main content

What you will build

You will call POST /v1/images/generations, generate one image with a GPT image model, decode the returned b64_json, and save it as an image file.

Prerequisites

  • A RunBridge AI API key stored in RUNBRIDGE_API_KEY
  • Python 3.10+ or Node.js 18+ for file-saving examples
  • A server-side environment. Do not call image generation from public frontend code with a secret key.

API key, base URL, authentication

Use the OpenAI-compatible image endpoint:
Authenticate with a Bearer token:

Code examples

Use the tabs below for copyable examples in cURL, Python, and Node.js.

Flow explanation

GPT image generation returns the completed response in one request. GPT image models return base64 image data in data[0].b64_json. Decode that value and write the bytes to a file that matches output_format.

Common parameters

Troubleshooting / FAQ

Confirm you decoded b64_json as base64 bytes and saved the file extension that matches output_format.
Image parameters vary by model. Start with the minimal reference example, then add one optional field at a time.

Next steps

Last modified on October 9, 2026