Quickstart

Follow these steps to generate your first image with ModelBeam.

Step 1: Create an Account

Sign up at modelbeam.ai/register. You will receive $5 in free credits immediately.

Step 2: Get Your API Key

  1. Go to modelbeam.ai/dashboard/api-keys
  2. Click Create API Key
  3. Copy the key — it will only be shown once

Step 3: Make Your First API Call

Generate an image with a single cURL command:
curl -X POST https://api.modelbeam.ai/api/v1/client/txt2img \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "prompt": "a cat floating in a nebula, photorealistic",
    "model": "Flux1schnell",
    "width": 768,
    "height": 768,
    "steps": 4,
    "guidance": 1,
    "seed": -1
  }'
Response:
{
  "data": {
    "request_id": "550e8400-e29b-41d4-a716-446655440000"
  }
}

Step 4: Poll for Results

Use the request_id to check the job status:
curl https://api.modelbeam.ai/api/v1/client/request-status/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json"
Response when complete:
{
  "data": {
    "status": "done",
    "preview": "base64_string_or_null",
    "result_url": "https://storage.modelbeam.ai/...",
    "results_alt_formats": null,
    "result": null,
    "progress": 100.0
  }
}

Step 5: Full Python Example

import requests
import time

API_KEY = "your_api_key"
BASE = "https://api.modelbeam.ai"
HEADERS = {
    "Authorization": f"Bearer {API_KEY}",
    "Accept": "application/json",
    "Content-Type": "application/json"
}

# 1. Discover models
models_resp = requests.get(
    f"{BASE}/api/v1/client/models",
    headers=HEADERS,
    params={"filter[inference_types]": "txt2img"}
)
models = models_resp.json()["data"]
model_slug = models[0]["slug"]
defaults = models[0]["info"]["defaults"]

# 2. Check price
payload = {
    "prompt": "a sunset over mountains",
    "model": model_slug,
    "width": defaults["width"],
    "height": defaults["height"],
    "steps": defaults["steps"],
    "guidance": 1,
    "seed": -1
}
price_resp = requests.post(
    f"{BASE}/api/v1/client/txt2img/price-calculation",
    headers=HEADERS,
    json=payload
)
price = price_resp.json()["data"]["price"]
print(f"Cost: ${price}")

# 3. Generate image
gen_resp = requests.post(
    f"{BASE}/api/v1/client/txt2img",
    headers=HEADERS,
    json=payload
)
request_id = gen_resp.json()["data"]["request_id"]
print(f"Job submitted: {request_id}")

# 4. Poll for result
while True:
    status_resp = requests.get(
        f"{BASE}/api/v1/client/request-status/{request_id}",
        headers=HEADERS
    )
    data = status_resp.json()["data"]
    if data["status"] == "done":
        print(f"Result: {data['result_url']}")
        break
    if data["status"] == "error":
        raise Exception("Generation failed")
    print(f"Status: {data['status']}, Progress: {data.get('progress', 0)}%")
    time.sleep(3)

Next Steps