AI image generation through the API | MozOut Mozambique
All in One AI / Images

AI for imagesWrite what you want and get the image

Describe the image you want and get it ready to use, in the Playground, through the API or in your coding agent.

One image

  • From a description
  • In the size you choose
  • Pay only when it is ready
  • Free Sandbox
Close-up of a camera lens
AI WorkspaceExample
gpt-image-2openai/gpt-image-2/text-to-image

A bright, modern office with plants and soft morning light.

Preview of the example image
Type your message
Estimated cost2 creditsestimate
Available600+text, image, video and audio models
How to ask

Write what you want and get the image

The clearer the description, the better the result: the place, the light, the colours and the style.

Young woman with headphones drawing on a tablet outdoors
Example requestA bright, modern office with plants and soft morning light
  • openai/gpt-image-2/text-to-image
  • size: 1024x1024
  • 2 credits per image (example)
Where to create

Three ways to create images

The same models and the same credits, wherever suits you best.

Smiling young man with headphones using a computer
  • In the Playground

    On the «Image» tab in My MozOut: type, choose the model and see the result, no code.

  • Through the API

    With POST /v1/media/generations, from your website or system, also in bulk.

  • In your agent

    In Claude Code, Codex or Cursor via our MCP server, or in the terminal with aio.

How it works

From the request to the finished image

The request answers at once, with the id and the reserved credits. Then you check the status every 5 seconds until the image is ready.

  1. processing

    Generating

    The request returns 202, the generation id and the reserved credits in credits_reserved.

  2. completed

    Ready

    Images in outputs, real cost in credits_charged. The rest of the reservation comes back.

  3. failed

    Failed

    The reason is in error. Nothing is charged and the whole reservation goes back to your balance.

Code

An image in a few lines

The OpenAI SDK does not have these operations: use plain HTTP requests. The model fields go in input, and you can see them in GET /v1/models/{id}.

  • Request: POST /v1/media/generations
  • Status: GET /v1/media/generations/{id}
  • Retries: with the Idempotency-Key header you never pay twice for the same image.
import os, time, requests

API = "https://api.mozout.co.mz/v1"
H = {"Authorization": "Bearer " + os.environ["MOZOUT_API_KEY"]}

job = requests.post(API + "/media/generations", headers=H, timeout=30, json={
    "model": "openai/gpt-image-2/text-to-image",
    "input": {"prompt": "A bright, modern office with plants and soft morning light",
              "size": "1024x1024"},
}).json()["data"]

while job["status"] == "processing":
    time.sleep(5)
    job = requests.get(API + "/media/generations/" + job["id"],
                       headers=H, timeout=30).json()["data"]

print(job["status"], job["outputs"], job["credits_charged"])
Good practice

Before you generate in bulk

What helps you get good images without wasting credits.

Studio with a computer, screens and lights for making video

Do

  • Try the description in the Playground before putting it in your code.
  • Check the model price in GET /v1/models and your balance in GET /v1/ai/balance.
  • Download the finished images and keep your own copy.
  • Write your program with the sandbox_ key: the generation completes at once, with 0 credits.

Avoid

  • Checking the status more often than every 5 seconds.
  • Keeping only the outputs link: it is not permanent.
  • Repeating a request without Idempotency-Key after a network failure.
  • Putting the key in code that runs in the browser.
Frequently asked questions

AI images

The price of each image, how long it takes and what happens when a generation fails.

Man with headphones focused on work at a computer
Still have questions?

Talk to us or look for the answer in the Knowledge Base.

How much does an image cost?

It depends on the model. Each image model has a price in credits per image, shown on the «Models» tab or in GET /v1/models.

For example, openai/gpt-image-2/text-to-image costs 2 credits per image.

How do I create my first image?
  1. Open All in One AI in My MozOut and go to the «Playground» tab.
  2. Choose «Image» and the model.
  3. Type the description and see the result, with no code.

The 100 free credits are enough to try it.

How long does it take?

From a few seconds to a few minutes, depending on the model.

The request answers at once with the generation id, and you check the status every 5 seconds until it is ready.

Do I pay if the generation fails?

No. A failed generation is not charged and the reserved credits go back to your balance. The reason is in the error field.

Do the image links last forever?

No. The outputs links are not permanent. Download the images and keep your own copy.

Can I choose the size?

Yes, on models that accept it. The fields of each model, such as size, are in GET /v1/models/{id}, with the accepted values and the default.

Can I generate images in Claude Code or Cursor?

Yes. Associate the tool with our MCP server and ask for the image in the conversation.

The agent uses the generate_image tool and can save it in your project.

Can I test without spending?

Yes, with a sandbox_ key. The API answers in the same format, but it calls no model and charges nothing:

  • the chat always answers «Resposta de teste (sandbox).»;
  • an image, video or voice is completed straight away, with a sample link and 0 credits;
  • the model list, the prices and the balance are the real ones.

When your program is ready, switch to the prod_ key.

What happens if I run out of credits?

The request does not go ahead and the API answers 402 with insufficient_credits. Nothing is charged, and the error says how much you need and how much you have.

Buy more on the «Buy credits» tab and try again. The credits arrive as soon as the payment is confirmed. In chat, a lower max_tokens also lowers the reservation.

Content creator setting up a microphone and headphones in a studio
Support

Need help?

If you still have questions or need more information, we have expert people ready to help you.

All in One AI

Your first image is one description away

Activate All in One AI, get 100 credits and create an image in the Playground.

  • 100 free credits on activation
  • A Sandbox to test without spending
  • One key for everything

Lightning OFFER

Web Hosting + FREE Domain **

:
:
:
Stay Online!
keyboard_arrow_up Drag Up
Logo MozOut

Premium OFFER

Web Hosting + FREE Domain **

Offer ends in:
:
:
:
Stay Online!
Close