Image Generation

Generate and edit images with an enabled model and the route pricing shown in Model Square.

Use a Zashmodel API key with an enabled image model. Model IDs, route permissions, parameters and prices come from the current catalog rather than another site’s image plans.

Check the route before generating

Open the model detail page to confirm image generation or editing support and the billing unit. A text-model key or a public catalog entry does not automatically grant image access.

View models and pricing →

Choose a model and API key

  1. Find a model that supports the image endpoint you need, and copy its exact ID.
  2. Create a key with access to the model’s route and enough quota. Confirm the account balance separately.
  3. Set ZASHMODEL_MODEL to that image model ID and use the environment variables below.

API keys and access →

Environment variables
export ZASHMODEL_API_KEY="YOUR_API_KEY"
export ZASHMODEL_BASE_URL="https://zashmodel.com/v1"
export ZASHMODEL_MODEL="YOUR_MODEL_ID"

Image endpoints

Image endpoints
Use caseEndpointContent-Type
Generate an imagePOST /v1/images/generationsapplication/json
Edit an imagePOST /v1/images/editsmultipart/form-data

OpenAI-compatible base URL: https://zashmodel.com/v1

Generate an image

This minimal example uses your selected image model and saves the JSON response. Add optional parameters only after checking that model’s documented capabilities.

POST /v1/images/generations
curl --fail-with-body "$ZASHMODEL_BASE_URL/images/generations" \
  -H "Authorization: Bearer $ZASHMODEL_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- -o generation.json <<JSON
{
  "model": "$ZASHMODEL_MODEL",
  "prompt": "A white ceramic cup on a grey table, soft natural light"
}
JSON

Edit an image

Put source.png in the current directory. Keep the Content-Type header unset so cURL can supply the multipart boundary. The model must support editing.

POST /v1/images/edits
curl --fail-with-body "$ZASHMODEL_BASE_URL/images/edits" \
  -H "Authorization: Bearer $ZASHMODEL_API_KEY" \
  -F "model=$ZASHMODEL_MODEL" \
  -F "image=@source.png" \
  -F "prompt=Keep the composition and lighting; make the cup dark blue." \
  -o edit.json

Optional image parameters

Optional image parameters
ParameterRequirementDescription
modelRequiredUse an exact image model ID available to your key.
promptRequiredDescribe the image to generate or the change to make.
size / quality / nModel-dependentAllowed sizes, quality levels and image counts depend on the model and route.
background / output_formatModel-dependentCheck support for transparency and output formats before sending these fields.
imageFor editsThe multipart example uploads one local reference image.
response_formatModel-dependentSome models return Base64, others return a temporary URL; follow the selected model’s response format.

URL references, multiple images, masks and streaming are not interchangeable across routes. Use the model-specific instructions instead of assuming these features are available everywhere.

Read and save the result

  • Read the error object before processing data. A saved JSON file may contain an API error rather than an image.
  • If data contains b64_json, decode the Base64 and save it with the actual output format. If it contains url, download the file before that URL expires.
  • Store the result in your own application or storage when you need to keep it. Follow the current data-handling policy for the selected service.

Pricing and retries

There is no single image price or universal size surcharge in this guide. Check per-image or token pricing, route multipliers and parameter conditions in Model Square, then reconcile the final charge in request logs.

High-resolution images and complex edits may take longer. If a request times out, check its log before repeating it: a client timeout does not prove that the upstream stopped processing.

Request logs → · Troubleshooting →