Home
Model Gateway
API
Skills
Circle NanopaymentsPrivate Beta
Machine Payment ProtocolPrivate Beta
Coming Soon
Blog
Back to Blog
TutorialsMay 21, 2026·AIsa Team

How to Generate Images with gpt-image-2-plus on AIsa

Learn how to call AIsa's image generation API with gpt-image-2-plus, save the JSON response, decode the base64 image, and view the final PNG locally.

gpt-image-2-plusimage-generationAIsa APIcurljqbase64tutorial
Share
How to Generate Images with gpt-image-2-plus on AIsa

AIsa now supports gpt-image-2 and gpt-image-2-plus for image generation through the AIsa API. This tutorial shows how to generate an image with gpt-image-2-plus, save the API response, decode the image, and open the final output locally.

What You Will Build

By the end of this tutorial, you will have:

  • Sent an image generation request to the AIsa API
  • Used gpt-image-2-plus as the image generation model
  • Saved the API response as a JSON file
  • Decoded the returned base64 image into a PNG file
  • Opened the generated image on your computer

Requirements

Before you begin, make sure you have:

  • An AIsa API key
  • A terminal environment
  • curl installed
  • jq installed
  • base64 available in your terminal

For Linux, macOS, or WSL on Windows, you can check whether jq is installed by running:

bash

If jq is not installed, install it with:

bash

Step 1: Export Your AIsa API Key

Before calling the AIsa API, export your API key as an environment variable.

bash

This allows you to use your API key securely in the request without pasting it directly into the command.

Important: Do not expose your API key in screen recordings, screenshots, public repositories, or shared files.

Step 2: Call the AIsa Image Generation API

Next, send a request to the AIsa image generation endpoint.

In this example, we are using gpt-image-2-plus to generate a cinematic, highly detailed image.

bash

What This Command Does

  • curl sends the request to the AIsa API.
  • https://api.aisa.one/v1/images/generations is the image generation endpoint.
  • Content-Type: application/json tells the API that the request body is JSON.
  • Authorization: Bearer $AISA_API_KEY authenticates the request with your AIsa API key.
  • "model": "gpt-image-2-plus" selects the image generation model.
  • "prompt" describes the image you want to generate.
  • "size": "1024x1024" sets the image size.
  • > future-classroom-response.json saves the full API response into a JSON file.

Step 3: Decode the Generated Image

The API response may return the generated image as base64 data inside the JSON response.

To extract and decode the image into a PNG file, run:

bash

What This Command Does

  • jq -r '.data[0].b64_json' future-classroom-response.json extracts the base64 image data from the JSON file.
  • base64 -d decodes the base64 data.
  • > future-classroom-elon-ai-mars.png saves the decoded image as a PNG file.

After this step, your generated image will be saved as:

text

Step 4: Open the Folder and View the Image

If you are using WSL on Windows, open the current folder in Windows File Explorer with:

bash

You should see both files:

text

Open the PNG file to view your generated image.

Optional: Use gpt-image-2 Instead

You can also use gpt-image-2 instead of gpt-image-2-plus.

Simply change this line:

json

to:

json

Use gpt-image-2-plus when you want higher-quality generations. Use gpt-image-2 when you want a standard image generation option.

Full Workflow Summary

bash

Best Practices

  • Keep your API key private.
  • Use environment variables instead of hardcoding API keys.
  • Save the API response to a .json file before decoding.
  • Use jq to extract image data properly.
  • Use detailed prompts for more controlled image outputs.
  • For official brand visuals, add logos and final text manually after generation for better accuracy.

Conclusion

With AIsa, you can generate images through a simple API call using gpt-image-2 or gpt-image-2-plus. The workflow is straightforward: send a prompt to the image generation endpoint, save the response, decode the returned image data, and open the final PNG.

This makes it easy for builders, creators, and AI agent developers to add image generation into their workflows through one unified API.