How to Submit Task
Submit generation tasks to WaveSpeedAI models via API.
Endpoint
POST https://api.wavespeed.ai/api/v3/{model-id}Request Format
curl --location --request POST 'https://api.wavespeed.ai/api/v3/wavespeed-ai/flux-dev' \
--header 'Authorization: Bearer ${WAVESPEED_API_KEY}' \
--header 'Content-Type: application/json' \
--data-raw '{
"prompt": "A cat wearing a space suit"
}'Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer ${WAVESPEED_API_KEY} |
Content-Type | Yes | application/json |
Request Body
The request body varies by model. Common parameters:
| Parameter | Type | Description |
|---|---|---|
prompt | string | Text description |
width | integer | Output width |
height | integer | Output height |
seed | integer | Random seed |
webhook_url | string | Callback URL |
Check the model’s documentation for specific parameters.
Response
{
"code": 200,
"message": "success",
"data": {
"id": "pred_abc123",
"model": "wavespeed-ai/flux-dev",
"status": "created",
"urls": {
"get": "https://api.wavespeed.ai/api/v3/predictions/pred_abc123"
},
"created_at": "2024-01-01T12:00:00.000Z"
}
}Response Fields
| Field | Description |
|---|---|
data.id | Task ID for polling |
data.status | Initial status (created) |
data.urls.get | URL to check status |
With Webhook
Receive notification when complete:
curl --location --request POST 'https://api.wavespeed.ai/api/v3/wavespeed-ai/flux-dev' \
--header 'Authorization: Bearer ${WAVESPEED_API_KEY}' \
--header 'Content-Type: application/json' \
--data-raw '{
"prompt": "A cat in space",
"webhook_url": "https://your-server.com/webhook"
}'Python Example
import os
import requests
api_key = os.environ.get("WAVESPEED_API_KEY")
response = requests.post(
"https://api.wavespeed.ai/api/v3/wavespeed-ai/flux-dev",
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
},
json={
"prompt": "A cat wearing a space suit"
}
)
task = response.json()["data"]
task_id = task["id"]
print(f"Task submitted: {task_id}")Error Responses
| Code | Description |
|---|---|
| 400 | Invalid parameters |
| 401 | Invalid API key |
| 403 | Account issue |
| 429 | Rate limit exceeded |
| 500 | Server error |
Next Steps
After submitting, use How to Get Result to retrieve your output.