Skip to content

API reference

Images

Generate or edit images using a model that advertises the capability. Choose direct generation or the product queue according to the operation.

How it fits together

  1. 01Dispatch image generation and return a run reference
  2. 02Edit one or more uploaded images
  3. 03Generate images

Select an action to see its complete inputs, request, response, and status codes.

Dispatch image generation and return a run reference

POST/api/v1/chat/images/generations
Production base URLhttps://api.mahvashai.ir
AuthenticationProject API key or user JWT
ResponseMahvash product envelope
Content typeapplication/json

Parameters

The table shows the accepted inputs for this endpoint. Examples use placeholders and illustrate a safe integration pattern.

NameLocationTypeRequiredSupportDetails
Idempotency-KeyHeaderstringOptionalSupportedReplay key for an admitted run; a repeat returns the first result.
X-Request-IDHeaderstringOptionalMahvash extensionClient-supplied correlation ID. Echoed on every response; replaced when absent or malformed.
X-Mahvash-ProjectHeaderstringOptionalMahvash extensionProject slug or ID within the caller's organization. Narrows the request principal; it can never widen it.
backgroundBodystringOptionalConditionalauto, transparent, or opaque. Transparent needs png or webp.
chat_idBodystringOptionalMahvash extensionAttach the generated image to an owned conversation.
modelBodystringOptionalSupportedPublic logical image model ID.
moderationBodystringOptionalConditionalauto or low.
nBodyintegerOptionalConditionalNumber of images, 1 to 10; above 1 needs route support.
output_compressionBodyintegerOptionalConditionalCompression level 0 to 100 for lossy output formats.
output_formatBodystringOptionalConditionalpng, jpeg, or webp.
promptBodystringRequiredSupportedImage prompt, up to 32,000 characters.
qualityBodystringOptionalConditionalauto, low, medium, high, standard, or hd.
response_formatBodystringOptionalConditionalb64_json or url. Mahvash always returns owned URLs.
sizeBodystringOptionalConditionalauto or WIDTHxHEIGHT within the configured bounds.
styleBodystringOptionalConditionalvivid or natural, for routes that accept it.
userBodystringOptionalSupportedProvider abuse-monitoring user identifier.

A compatible model and provider route are required for conditional fields.

Request

curl -X POST 'https://api.mahvashai.ir/api/v1/chat/images/generations' \
  -H "Authorization: Bearer $MAHVASH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: <unique-request-id>" \
  -d '{
  "prompt": "a red bicycle"
}'

Response

{
  "status": 0,
  "data": "<value>"
}

Illustrative response shape; actual fields depend on the operation and model.

Status codes

HTTPDetails
202Dispatch image generation and return a run reference.
400The request is not valid.
401Authentication credentials are missing or invalid.
402The account cannot authorize the request cost.
403The principal is not allowed to perform this request.
404No such resource is visible to this principal.
409The requested transition conflicts with durable resource state.
429A quota or rate limit was exceeded.
500An internal error occurred.
503A dependency is temporarily unavailable.

Edit one or more uploaded images

POST/v1/images/edits
Production base URLhttps://api.mahvashai.ir
AuthenticationProject API key or user JWT
ResponseDirect OpenAI-style response
Content typemultipart/form-data

Parameters

The table shows the accepted inputs for this endpoint. Examples use placeholders and illustrate a safe integration pattern.

NameLocationTypeRequiredSupportDetails
Idempotency-KeyHeaderstringOptionalSupportedReplay key for an admitted run; a repeat returns the first result.
X-Request-IDHeaderstringOptionalMahvash extensionClient-supplied correlation ID. Echoed on every response; replaced when absent or malformed.
X-Mahvash-ProjectHeaderstringOptionalMahvash extensionProject slug or ID within the caller's organization. Narrows the request principal; it can never widen it.
backgroundFormstringOptionalConditionalauto, transparent, or opaque. Transparent needs png or webp.
imageFormarray<string> (binary)RequiredSupported1 to 16 input images.
input_fidelityFormstringOptionalConditionallow or high; rejected for models that always use high.
maskFormstring (binary)OptionalSupportedAlpha mask matching the first image's format and size.
modelFormstringOptionalSupportedPublic logical image model ID.
moderationFormstringOptionalConditionalauto or low.
nFormintegerOptionalConditionalNumber of images, 1 to 10; above 1 needs route support.
output_compressionFormintegerOptionalConditionalCompression level 0 to 100 for lossy output formats.
output_formatFormstringOptionalConditionalpng, jpeg, or webp.
promptFormstringRequiredSupportedImage prompt, up to 32,000 characters.
qualityFormstringOptionalConditionalauto, low, medium, high, standard, or hd.
response_formatFormstringOptionalConditionalb64_json or url. Mahvash always returns owned URLs.
sizeFormstringOptionalConditionalauto or WIDTHxHEIGHT within the configured bounds.
userFormstringOptionalSupportedProvider abuse-monitoring user identifier.

A compatible model and provider route are required for conditional fields.

Request

curl -X POST 'https://api.mahvashai.ir/v1/images/edits' \
  -H "Authorization: Bearer $MAHVASH_API_KEY" \
  -H "Idempotency-Key: <unique-request-id>" \
  -F 'image=@./your-file' \
  -F 'prompt=a red bicycle'

Response

{
  "data": [
    {
      "url": "https://example.com/resource"
    }
  ],
  "created": 1750000000
}

Illustrative response shape; actual fields depend on the operation and model.

Status codes

HTTPDetails
200Edit one or more uploaded images.
400The request is not valid.
401Authentication credentials are missing or invalid.
402The account cannot authorize the request cost.
403The principal is not allowed to perform this request.
404No such resource is visible to this principal.
409The requested transition conflicts with durable resource state.
429A quota or rate limit was exceeded.
500An internal error occurred.
502The selected provider returned an invalid or failed response.
503A dependency is temporarily unavailable.

Generate images

POST/v1/images/generations
Production base URLhttps://api.mahvashai.ir
AuthenticationProject API key or user JWT
ResponseDirect OpenAI-style response
Content typeapplication/json

Parameters

The table shows the accepted inputs for this endpoint. Examples use placeholders and illustrate a safe integration pattern.

NameLocationTypeRequiredSupportDetails
Idempotency-KeyHeaderstringOptionalSupportedReplay key for an admitted run; a repeat returns the first result.
X-Request-IDHeaderstringOptionalMahvash extensionClient-supplied correlation ID. Echoed on every response; replaced when absent or malformed.
X-Mahvash-ProjectHeaderstringOptionalMahvash extensionProject slug or ID within the caller's organization. Narrows the request principal; it can never widen it.
backgroundBodystringOptionalConditionalauto, transparent, or opaque. Transparent needs png or webp.
modelBodystringOptionalSupportedPublic logical image model ID.
moderationBodystringOptionalConditionalauto or low.
nBodyintegerOptionalConditionalNumber of images, 1 to 10; above 1 needs route support.
output_compressionBodyintegerOptionalConditionalCompression level 0 to 100 for lossy output formats.
output_formatBodystringOptionalConditionalpng, jpeg, or webp.
promptBodystringRequiredSupportedImage prompt, up to 32,000 characters.
qualityBodystringOptionalConditionalauto, low, medium, high, standard, or hd.
response_formatBodystringOptionalConditionalb64_json or url. Mahvash always returns owned URLs.
sizeBodystringOptionalConditionalauto or WIDTHxHEIGHT within the configured bounds.
styleBodystringOptionalConditionalvivid or natural, for routes that accept it.
userBodystringOptionalSupportedProvider abuse-monitoring user identifier.

A compatible model and provider route are required for conditional fields.

Request

curl -X POST 'https://api.mahvashai.ir/v1/images/generations' \
  -H "Authorization: Bearer $MAHVASH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: <unique-request-id>" \
  -d '{
  "prompt": "a red bicycle"
}'

Response

{
  "data": [
    {
      "url": "https://example.com/resource"
    }
  ],
  "created": 1750000000
}

Illustrative response shape; actual fields depend on the operation and model.

Status codes

HTTPDetails
200Generate images.
400The request is not valid.
401Authentication credentials are missing or invalid.
402The account cannot authorize the request cost.
403The principal is not allowed to perform this request.
404No such resource is visible to this principal.
409The requested transition conflicts with durable resource state.
429A quota or rate limit was exceeded.
500An internal error occurred.
502The selected provider returned an invalid or failed response.
503A dependency is temporarily unavailable.