curl --request POST 'https://api.voicecheap.ai/v1/actions/images_generate' \
--header "x-api-key: $VOICECHEAP_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"requestId":"61becb70-00d6-4de0-9eb1-05829a0d851c","prompt":"A peaceful coastal village at sunrise, with warm natural light.","aspectRatio":"square","referenceImageKey":"uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png"}'
const input = {
requestId: '61becb70-00d6-4de0-9eb1-05829a0d851c',
prompt: 'A peaceful coastal village at sunrise, with warm natural light.',
aspectRatio: 'square',
referenceImageKey: 'uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png',
};
const response = await fetch('https://api.voicecheap.ai/v1/actions/images_generate', {
method: 'POST',
headers: {
'x-api-key': process.env.VOICECHEAP_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify(input),
});
const body = await response.json();
if (!response.ok) throw new Error(body.code + ': ' + body.message);
console.log(body);
import os
import requests
response = requests.post(
"https://api.voicecheap.ai/v1/actions/images_generate",
headers={"x-api-key": os.environ["VOICECHEAP_API_KEY"]},
json={"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c", "prompt": "A peaceful coastal village at sunrise, with warm natural light.", "aspectRatio": "square", "referenceImageKey": "uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png"},
timeout=120,
)
body = response.json()
if not response.ok:
raise RuntimeError(f"{body.get('code')}: {body.get('message')}")
print(body)
{
"data": {
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c",
"status": "running",
"pollAction": "action_request_get",
"pollAfterSeconds": 5
},
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c"
}
{
"data": {
"generationId": "6224018c7635dcb933ce5c8f7804aea73738dd1c",
"status": "completed",
"aspectRatio": "square",
"width": 1024,
"height": 1024,
"referenceImageCount": 1,
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"expiresAt": 1792749600000
},
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c"
}
{
"data": {
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c",
"operation": "images_generate",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "running",
"pollAfterSeconds": 5
},
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c"
}
{
"data": {
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c",
"operation": "images_generate",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "completed",
"resultStored": false,
"message": "The action completed. Retrieve its output from the corresponding history or resource action."
},
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c"
}
Images
Generate an image
Generate an image for the connected account. Uses the same media allowance and safeguards as the web app. Save the returned generationId and use images_download to retrieve the image. Reuse requestId when retrying the same request.
POST
/
v1
/
actions
/
images_generate
curl --request POST 'https://api.voicecheap.ai/v1/actions/images_generate' \
--header "x-api-key: $VOICECHEAP_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"requestId":"61becb70-00d6-4de0-9eb1-05829a0d851c","prompt":"A peaceful coastal village at sunrise, with warm natural light.","aspectRatio":"square","referenceImageKey":"uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png"}'
const input = {
requestId: '61becb70-00d6-4de0-9eb1-05829a0d851c',
prompt: 'A peaceful coastal village at sunrise, with warm natural light.',
aspectRatio: 'square',
referenceImageKey: 'uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png',
};
const response = await fetch('https://api.voicecheap.ai/v1/actions/images_generate', {
method: 'POST',
headers: {
'x-api-key': process.env.VOICECHEAP_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify(input),
});
const body = await response.json();
if (!response.ok) throw new Error(body.code + ': ' + body.message);
console.log(body);
import os
import requests
response = requests.post(
"https://api.voicecheap.ai/v1/actions/images_generate",
headers={"x-api-key": os.environ["VOICECHEAP_API_KEY"]},
json={"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c", "prompt": "A peaceful coastal village at sunrise, with warm natural light.", "aspectRatio": "square", "referenceImageKey": "uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png"},
timeout=120,
)
body = response.json()
if not response.ok:
raise RuntimeError(f"{body.get('code')}: {body.get('message')}")
print(body)
{
"data": {
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c",
"status": "running",
"pollAction": "action_request_get",
"pollAfterSeconds": 5
},
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c"
}
{
"data": {
"generationId": "6224018c7635dcb933ce5c8f7804aea73738dd1c",
"status": "completed",
"aspectRatio": "square",
"width": 1024,
"height": 1024,
"referenceImageCount": 1,
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"expiresAt": 1792749600000
},
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c"
}
{
"data": {
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c",
"operation": "images_generate",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "running",
"pollAfterSeconds": 5
},
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c"
}
{
"data": {
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c",
"operation": "images_generate",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "completed",
"resultStored": false,
"message": "The action completed. Retrieve its output from the corresponding history or resource action."
},
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c"
}
Generate an image for the connected account. Uses the same media allowance and safeguards as the web app. Save the returned generationId and use images_download to retrieve the image. Reuse requestId when retrying the same request.
Required permissions:
POST https://api.voicecheap.ai/v1/actions/images_generate
Authentication and permissions
string
required
Send a VoiceCheap API key in this header. Authorization: Bearer with the same API key is also supported. OAuth access tokens are accepted only by
MCP, not by this REST endpoint.
images:write.
An active paid subscription is required. Permissions do not change team roles, resource ownership, media credits, or plan limits.
Parameters
string
Optional at the transport boundary: the server injects an identifier before validation when omitted. Supply your own stable UUID v4 to recover safely from a lost response.Format: “uuid”. Pattern:
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$.string
required
Text value.Minimum length: 10. Maximum length: 1200.
string
Text value.Allowed values: “square”, “landscape”, “portrait”. Default: “square”.
string
An uploaded JPG, PNG or WebP object key under uploads/{yourUserId}/. Remote URLs are not accepted.Minimum length: 1. Maximum length: 512.
Complete input schema
Complete input schema
The JSON Schema below preserves the exact field names, nested types, defaults, bounds, and accepted values exposed by discovery. Additional cross-field rules are listed in the operation notes.
{
"type": "object",
"properties": {
"requestId": {
"type": "string",
"format": "uuid",
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
"description": "UUID v4 for this action. Reuse the same ID with identical arguments on retries."
},
"prompt": {
"type": "string",
"minLength": 10,
"maxLength": 1200
},
"aspectRatio": {
"default": "square",
"type": "string",
"enum": ["square", "landscape", "portrait"]
},
"referenceImageKey": {
"type": "string",
"minLength": 1,
"maxLength": 512,
"description": "An uploaded JPG, PNG or WebP object key under uploads/{yourUserId}/. Remote URLs are not accepted."
}
},
"required": ["prompt"],
"additionalProperties": false
}
Idempotency
Use a UUID v4 in requestId or the Idempotency-Key HTTP header for each mutation. Reuse the same identifier and identical arguments after a network failure. If both are supplied, they must match. Replaying a saved request does not repeat the operation or charge another monthly call. Failed or interrupted requests are not restarted automatically. Every mutation can return HTTP 202 when a retry finds the same request still running, even when its first execution is normally synchronous. If execution completed but resultStored is false, a retry returns HTTP 200 with saved request state instead of the original result. Retrieve the output through its domain history, result, or download action.Request examples
Replace example resource identifiers and media keys with values returned for your account. Keep the request identifier stable when retrying the same mutation.curl --request POST 'https://api.voicecheap.ai/v1/actions/images_generate' \
--header "x-api-key: $VOICECHEAP_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"requestId":"61becb70-00d6-4de0-9eb1-05829a0d851c","prompt":"A peaceful coastal village at sunrise, with warm natural light.","aspectRatio":"square","referenceImageKey":"uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png"}'
const input = {
requestId: '61becb70-00d6-4de0-9eb1-05829a0d851c',
prompt: 'A peaceful coastal village at sunrise, with warm natural light.',
aspectRatio: 'square',
referenceImageKey: 'uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png',
};
const response = await fetch('https://api.voicecheap.ai/v1/actions/images_generate', {
method: 'POST',
headers: {
'x-api-key': process.env.VOICECHEAP_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify(input),
});
const body = await response.json();
if (!response.ok) throw new Error(body.code + ': ' + body.message);
console.log(body);
import os
import requests
response = requests.post(
"https://api.voicecheap.ai/v1/actions/images_generate",
headers={"x-api-key": os.environ["VOICECHEAP_API_KEY"]},
json={"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c", "prompt": "A peaceful coastal village at sunrise, with warm natural light.", "aspectRatio": "square", "referenceImageKey": "uploads/example-user/2502829e-3fde-4aad-b3c7-ce0f779fa2e6-reference.png"},
timeout=120,
)
body = response.json()
if not response.ok:
raise RuntimeError(f"{body.get('code')}: {body.get('message')}")
print(body)
Response
This operation returns HTTP 202 while running. Save requestId and poll action_request_get with that identifier and the original operation name. Polling states are running, completed, failed, and interrupted. A completed result can point to a separate media job; continue with the operation-specific status or output action. Final generation metadata returned by the handler after image generation finishes. No image bytes, previewDataUrl, or download URL are included.{
"data": {
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c",
"status": "running",
"pollAction": "action_request_get",
"pollAfterSeconds": 5
},
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c"
}
{
"data": {
"generationId": "6224018c7635dcb933ce5c8f7804aea73738dd1c",
"status": "completed",
"aspectRatio": "square",
"width": 1024,
"height": 1024,
"referenceImageCount": 1,
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"expiresAt": 1792749600000
},
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c"
}
{
"data": {
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c",
"operation": "images_generate",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "running",
"pollAfterSeconds": 5
},
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c"
}
{
"data": {
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c",
"operation": "images_generate",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"status": "completed",
"resultStored": false,
"message": "The action completed. Retrieve its output from the corresponding history or resource action."
},
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c"
}
Result fields
| Field | Description |
|---|---|
data.generationId | Identifier to pass unchanged to images_get or images_download. |
data.status | pending, completed, failed, or expired. Expiry takes precedence over the stored status. |
data.aspectRatio | square, landscape, or portrait. |
data.width | Output width in pixels, or null before dimensions are available. |
data.height | Output height in pixels, or null before dimensions are available. |
data.referenceImageCount | Number of reference images used: 0 or 1. |
data.createdAt | Creation time in Unix milliseconds. |
data.updatedAt | Last update time in Unix milliseconds. |
data.expiresAt | Time in Unix milliseconds after which the generated image cannot be downloaded. |
Recover and poll this request
Use the same identifier even after a lost connection. If resultStored is false, retrieve the output through the corresponding history, result, or download action. Never start a second generation merely to check progress.curl --request POST 'https://api.voicecheap.ai/v1/actions/action_request_get' \
--header "x-api-key: $VOICECHEAP_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"requestId":"61becb70-00d6-4de0-9eb1-05829a0d851c","operation":"images_generate"}'
HTTP 200
{
"data": {
"requestId": "61becb70-00d6-4de0-9eb1-05829a0d851c",
"operation": "images_generate",
"status": "completed",
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"resultStored": true,
"result": {
"generationId": "6224018c7635dcb933ce5c8f7804aea73738dd1c",
"status": "completed",
"aspectRatio": "square",
"width": 1024,
"height": 1024,
"referenceImageCount": 1,
"createdAt": 1792144800000,
"updatedAt": 1792144820000,
"expiresAt": 1792749600000
}
}
}
Operation notes
- Requires images:write. The prompt is trimmed and must contain 10–1200 characters; it is also normalized before generation. aspectRatio is square by default and also accepts landscape or portrait. At most one referenceImageKey is accepted.
- This is a long-running action. The initial API/MCP response normally reports running; poll action_request_get with operation images_generate and the same requestId to obtain the final result shown here.
- Uses the account’s normal daily image-generation allowance. Generated account images expire seven days after creation; download the result before expiresAt.
- This action uses the connected user’s own creations and uploads, including when the credential is connected in a team context.
- Reference keys must point to completed uploads under uploads/{yourUserId}/ and end in .jpg, .jpeg, .png, or .webp. Remote URLs, other users’ keys, traversal segments, backslashes, percent escapes, query strings, fragments, and control characters are rejected.
- Each reference must be non-empty, at most 8 MiB (8,388,608 bytes), decode as the image type identified by its extension, and measure 128–4096 pixels on each side. Decoded pixel counts are bounded as well. An uploaded reference remains reusable; these generation actions do not consume or delete its uploaded file.
- Use a UUID v4 requestId, or the HTTP Idempotency-Key header, and reuse it with identical inputs when retrying. The integration layer records each mutation and returns its recorded state or result without rerunning it. A failed or interrupted request is not automatically retried.
- Only one image may be generated for this user at a time. Use images_list and images_get to inspect creation state, and images_download for PNG bytes. The generation identifier is an opaque string; do not replace it with requestId.
Usage
Each successful invocation consumes one monthly API/MCP call. Media credits and the operation’s own generation allowances also apply.Errors
| HTTP status | Code | Meaning or recovery |
|---|---|---|
| 400 | BAD_REQUEST | The server could not determine the trusted request network context. |
| 400 | CREDENTIAL_IN_QUERY | Credentials were supplied in an access_token or api_key query parameter. Send credentials in headers. |
| 400 | IDEMPOTENCY_CONFLICT | The Idempotency-Key header and requestId body field must match. |
| 400 | IMAGE_PROMPT_INVALID | The normalized prompt is outside the 10–1200 character range. |
| 400 | IMAGE_REFERENCE_INVALID | The reference bytes do not match the supported image type, byte limit, dimensions, or decoding requirements. |
| 400 | INVALID_REQUEST_ID | requestId or Idempotency-Key is not a UUID v4. |
| 400 | REFERENCE_IMAGE_INVALID | The reference key is unsafe, unowned, unsupported, unavailable, or larger than 8 MiB. |
| 400 | VALIDATION_ERROR | An argument is missing, has an unsupported value, exceeds its limit, or is not part of the strict input schema. |
| 401 | API_KEY_EXPIRED | The API key has expired. |
| 401 | INVALID_API_KEY | Provide a valid, unexpired API key. |
| 401 | INVALID_CREDENTIAL | The Authorization header is malformed or conflicts with x-api-key. |
| 401 | MISSING_CREDENTIAL | No usable header credential was supplied, or it exceeded 4096 characters. |
| 401 | USER_NOT_FOUND | The credential’s account no longer exists. |
| 403 | ACCOUNT_UNAVAILABLE | The acting or billing account is unavailable or being deleted. |
| 403 | AMBIGUOUS_TEAM_API_KEY | The credential’s user belongs to more than one team, so the billing context is ambiguous. |
| 403 | INSUFFICIENT_SCOPE | Grant every required permission or choose another credential. |
| 403 | INTEGRATION_PLAN_UNSUPPORTED | The account’s integration limits could not be verified. |
| 403 | SUBSCRIPTION_REQUIRED | Use an active paid subscription. |
| 403 | TEAM_OWNER_NOT_FOUND | The effective team owner account could not be found. |
| 409 | CONCURRENT_ACTION_LIMIT_REACHED | This account already has 10 integration actions running. Poll an existing request before starting another. |
| 409 | IDEMPOTENCY_CONFLICT | The request identifier was already used with different arguments; a header/body identifier mismatch returns HTTP 400 with the same code. |
| 409 | IMAGE_GENERATION_IN_PROGRESS | This image request or another image for the connected user is still running. |
| 409 | IMAGE_REQUEST_ID_REUSED | The image request identifier is already associated with different input. |
| 422 | IMAGE_REQUEST_REJECTED | The image cannot be generated from this prompt or reference. Change the content for a new request. |
| 429 | IMAGE_DAILY_LIMIT_REACHED | The account’s daily image-generation allowance is exhausted. |
| 429 | INTEGRATION_MONTHLY_LIMIT_REACHED | Wait for the monthly reset or change plan. |
| 429 | INTEGRATION_RATE_LIMIT_REACHED | Wait for Retry-After when present and use backoff. |
| 500 | INTERNAL_ERROR | Check saved request state and resource history before deciding to retry a mutation. |
| 502 | INTERNAL_ERROR | Generation or preparation of the image failed. Inspect request state before deciding to start another generation. |
| 503 | ACTION_RESULT_UNAVAILABLE | The action ran but its result could not be saved. Inspect saved request state and resource history before starting a new generation. |
| 503 | INTERNAL_ERROR | Image generation or its stored result is temporarily unavailable. Inspect request state before retrying. |
| 503 | SERVER_RESTARTING | The server is restarting. Retry shortly and keep the same request identifier for a mutation. |
{
"code": "INSUFFICIENT_SCOPE",
"message": "This credential does not permit the requested action.",
"status": 403,
"details": {
"requiredScopes": ["images:write"]
}
}
Was this page helpful?

