Skip to main content

Steps

1

Register Modellix

Log in to the Modellix console.
2

Get API Key

In the Modellix console, go to “API Key” and create an API Key.
The API Key is only displayed once after creation, so be sure to save it first.
3

Use the API

Find the model you want to use in Model API, or Model Index, and call the API using your API Key. For example:
Since model calls are asynchronous tasks, after a successful call, you will first receive a task_id as shown below:
4

Get the Result

You can query the task result later using the task_id. For example:
After a successful query, you will get the generated result. For example:
The model’s generated results will all be placed in the result object.
You can find the generated image URL in the result. For example:
5

Enjoy the Result

You have now successfully used the Modellix model API and obtained the generated result.
Generated results are only saved for 7 days, so please make sure to save them promptly.

Error Handling

All error responses follow a unified JSON format:
  • code (integer) — equals the HTTP status code (0 on success)
  • message (string) — formatted as "<Category>: <detail>"

Error Codes

HTTP StatusDescriptionCommon ScenariosRetryable
400Bad RequestMissing required parameters, invalid format, invalid valuesNo — fix parameters first
401UnauthorizedInvalid API key, missing API key, expired API keyNo — provide a valid key
402Payment RequiredInsufficient balance, account in arrearsNo — recharge your account
404Not FoundTask ID not found, model not found, provider not foundNo — check resource ID
429Too Many RequestsRate limit exceeded, concurrent limit exceededYes — use exponential backoff
500Internal Server ErrorInternal processing error, unexpected errorYes — retry up to 3 times
503Service UnavailableService temporarily unavailable, circuit breaker openYes — retry with backoff
For 429 responses, check the X-RateLimit-Reset header to know when you can retry. Use exponential backoff (1 s → 2 s → 4 s) for 500 and 503 errors.

Webhooks

Modellix supports webhooks to notify your application automatically when a media generation task is completed. Instead of polling the task status, you can configure a Webhook URL to receive the task results asynchronously.

Triggering Webhooks

To enable webhooks for a task, include the X-Webhook-URL header when calling any prediction creation API:
Once the task reaches a terminal state, the system asynchronously sends a POST request to this URL. Terminal states include:
  • success
  • failed
  • canceled

Webhook URL Requirements

Your webhook endpoint must meet the following requirements:
  • Must be a publicly accessible HTTPS address.
  • Cannot be localhost or 127.0.0.1.
  • Cannot be a private IP address (e.g., 10.x.x.x, 172.16.x.x to 172.31.x.x, 192.168.x.x).
  • Cannot contain username and password credentials in the URL.
For local development and testing, you can use tools like ngrok or cloudflared to expose your local server via a public HTTPS URL.

Callback Request

The system will initiate a POST request to your configured X-Webhook-URL with the following headers:
HeaderDescription
Content-TypeAlways application/json
User-AgentAlways modellix-webhook/1.0
X-Modellix-EventThe event type that triggered the webhook
X-Modellix-Task-IDThe unique ID of the generation task
X-Modellix-Delivery-IDThe unique ID of this webhook delivery attempt
X-Modellix-Retry-CountThe number of retries for this delivery (starts at 0)

Event Types

The X-Modellix-Event header can have one of the following values:
  • prediction.task.succeeded — Sent when the task completes successfully.
  • prediction.task.failed — Sent when the task fails.
  • prediction.task.canceled — Sent when the task is canceled.

Callback Payload

The webhook request body structure is identical to the response of the Query Task Result API.

Receiver Response Requirements

To acknowledge receipt of the webhook, your server must return an HTTP 2xx status code.
  • Recommended response: HTTP/1.1 200 OK with a plain text body of ok.
  • Alternative response: HTTP/1.1 204 No Content with an empty body.
The Modellix webhook system only checks the HTTP status code and does not parse or validate the response body.

Retry Rules

If delivery fails, the system will attempt to redeliver the webhook under specific conditions.

Retried Errors

The system will automatically retry delivery for the following errors:
  • HTTP status 429 (Too Many Requests)
  • HTTP status 5xx (Server Errors)
  • Network timeouts
  • Temporary network errors

Non-Retried Errors

The system will not retry delivery for the following errors:
  • HTTP status 3xx (Redirection)
  • HTTP status 4xx (Client Errors, except 429)
  • Invalid Webhook URLs
  • URLs pointing to private networks or localhost
  • Permanent connection errors (e.g., connection refused, unresolved DNS)

Best Practices

To ensure reliable and secure webhook processing, we recommend following these guidelines:
  1. Idempotency: Use the X-Modellix-Delivery-ID header to deduplicate incoming webhooks and prevent processing the same event multiple times.
  2. Asynchronous Processing: To avoid timeouts, quickly persist the incoming payload or push it to a message queue, and immediately return a 200 or 204 response. Perform any heavy business logic asynchronously.
  3. Security: Verify the request source or signature (if signature verification is supported in a future update).