
If POST https://api.hiapi.ai/v1/tasks rejects a request because the model is unavailable or the request is invalid, the task was not created. Check the exact model name and request fields against the current model documentation before retrying.
gpt-image-2/text-to-image.route field or the supported @route form, but do not send conflicting values.401 means the API key is missing or invalid. A 403 means the key does not have permission. Fix those separately from the model field.gpt-image-2/text-to-image.input with that model's parameter table. A valid model name can still return 400 INVALID_REQUEST when an input field is unsupported.model = os.environ["MODEL"].strip(); in Node.js, use model.trim().route value and use the parameter shape for that route.401/403.curl -X POST https://api.hiapi.ai/v1/tasks \
-H "Authorization: Bearer $HIAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2/text-to-image",
"input": {
"prompt": "a small ceramic mug on a wooden table, soft window light",
"aspect_ratio": "1:1",
"resolution": "1K"
}
}'
An HTTP 200 response with data.taskId means the task was accepted. Poll GET /v1/tasks/:id until data.status is success or fail, or configure a callback for production. For a 400, read the validation message and re-check the model page. For a 401 or 403, fix the key or its permissions.
Should I strip /text-to-image from every model name?
No. Model naming differs by family. Copy the fixed value from the current model documentation. For GPT Image 2 text-to-image, /text-to-image is part of the model name.
Does a model error mean my key is wrong?
Not necessarily. Request validation and authentication are separate. A 401 means the key is missing or invalid; a 403 means it lacks permission. A 400 points to the request shape, model name, route, or input fields.
Can I normalize all model names in my client? Avoid inventing a normalization rule. Store and send the exact names published in the current model documentation.