Steps
Register Modellix
Log in to the Modellix console.
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.
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:Get the Result
You can query the task result later using the After a successful query, you will get the generated result. For example:You can find the generated image URL in the
task_id. For example:The model’s generated results will all be placed in the
result object.result. For example:Error Handling
All error responses follow a unified JSON format:code(integer) — equals the HTTP status code (0on success)message(string) — formatted as"<Category>: <detail>"
Error Codes
| HTTP Status | Description | Common Scenarios | Retryable |
|---|---|---|---|
| 400 | Bad Request | Missing required parameters, invalid format, invalid values | No — fix parameters first |
| 401 | Unauthorized | Invalid API key, missing API key, expired API key | No — provide a valid key |
| 402 | Payment Required | Insufficient balance, account in arrears | No — recharge your account |
| 404 | Not Found | Task ID not found, model not found, provider not found | No — check resource ID |
| 429 | Too Many Requests | Rate limit exceeded, concurrent limit exceeded | Yes — use exponential backoff |
| 500 | Internal Server Error | Internal processing error, unexpected error | Yes — retry up to 3 times |
| 503 | Service Unavailable | Service temporarily unavailable, circuit breaker open | Yes — retry with backoff |
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 theX-Webhook-URL header when calling any prediction creation API:
POST request to this URL. Terminal states include:
successfailedcanceled
Webhook URL Requirements
Your webhook endpoint must meet the following requirements:- Must be a publicly accessible HTTPS address.
- Cannot be
localhostor127.0.0.1. - Cannot be a private IP address (e.g.,
10.x.x.x,172.16.x.xto172.31.x.x,192.168.x.x). - Cannot contain username and password credentials in the URL.
Callback Request
The system will initiate aPOST request to your configured X-Webhook-URL with the following headers:
| Header | Description |
|---|---|
Content-Type | Always application/json |
User-Agent | Always modellix-webhook/1.0 |
X-Modellix-Event | The event type that triggered the webhook |
X-Modellix-Task-ID | The unique ID of the generation task |
X-Modellix-Delivery-ID | The unique ID of this webhook delivery attempt |
X-Modellix-Retry-Count | The number of retries for this delivery (starts at 0) |
Event Types
TheX-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 HTTP2xx status code.
- Recommended response:
HTTP/1.1 200 OKwith a plain text body ofok. - Alternative response:
HTTP/1.1 204 No Contentwith 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, except429) - 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:- Idempotency: Use the
X-Modellix-Delivery-IDheader to deduplicate incoming webhooks and prevent processing the same event multiple times. - Asynchronous Processing: To avoid timeouts, quickly persist the incoming payload or push it to a message queue, and immediately return a
200or204response. Perform any heavy business logic asynchronously. - Security: Verify the request source or signature (if signature verification is supported in a future update).