Get Started with API

Get Started with API

Start making API calls to WaveSpeedAI in minutes.

Step 1: Get Your API Key

  1. Go to API Keys
  2. Enter a name and click Generate
  3. Copy your key and save it securely

API Keys Page

Important: API keys require a top-up to activate. Keys generated without a top-up will not work.

Step 2: Submit a Task

Send a POST request to generate content. Here’s an example using the FLUX model:

cURL

curl -X POST "https://api.wavespeed.ai/api/v3/wavespeed-ai/flux-dev" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "A cat wearing a space suit"}'

Python

import requests
 
response = requests.post(
    "https://api.wavespeed.ai/api/v3/wavespeed-ai/flux-dev",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
    },
    json={"prompt": "A cat wearing a space suit"}
)
 
data = response.json()
print(data)

JavaScript

const apiKey = "YOUR_API_KEY";
 
fetch("https://api.wavespeed.ai/api/v3/wavespeed-ai/flux-dev", {
    method: "POST",
    headers: {
        "Authorization": `Bearer ${apiKey}`,
        "Content-Type": "application/json"
    },
    body: JSON.stringify({
        prompt: "A cat wearing a space suit"
    })
})
.then(res => res.json())
.then(data => console.log(data));

Response:

{
  "code": 200,
  "message": "success",
  "data": {
    "id": "abc123-task-id",
    "status": "pending",
    "urls": {
      "get": "https://api.wavespeed.ai/api/v3/predictions/abc123-task-id/result"
    }
  }
}

Save the id or urls.get — you’ll need it to retrieve your result.

Step 3: Get the Result

Poll the result URL until the task is complete:

cURL

curl "https://api.wavespeed.ai/api/v3/predictions/abc123-task-id/result" \
  -H "Authorization: Bearer YOUR_API_KEY"

Python

import time
import requests
 
task_id = "abc123-task-id"  # From Step 2 response
 
while True:
    response = requests.get(
        f"https://api.wavespeed.ai/api/v3/predictions/{task_id}/result",
        headers={"Authorization": "Bearer YOUR_API_KEY"}
    )
    data = response.json()
 
    if data["data"]["status"] == "completed":
        print("Done!", data["data"]["outputs"])
        break
    elif data["data"]["status"] == "failed":
        print("Failed:", data["data"]["error"])
        break
 
    time.sleep(1)  # Wait 1 second before checking again

Response (completed):

{
  "code": 200,
  "message": "success",
  "data": {
    "id": "abc123-task-id",
    "status": "completed",
    "outputs": [
      "https://cdn.wavespeed.ai/outputs/image-xxxxx.png"
    ]
  }
}

The outputs array contains URLs to your generated content.

API Reference

ItemValue
Base URLhttps://api.wavespeed.ai/api/v3
Auth HeaderAuthorization: Bearer YOUR_API_KEY
Content Typeapplication/json

Task Status Values

StatusDescription
pendingTask is queued
processingTask is running
completedTask finished successfully
failedTask failed (check error field)

Next Steps

© 2025 WaveSpeedAI. All rights reserved.