I work at ModelFold. This walkthrough uses one mf-... key for an image job and a video job, then polls until each job finishes. The URLs, model IDs, and field names below are copied from the live docs on 26 November 2026: Async jobs, polling and callbacks and API Gateway /v1. Open those pages for the current parameter reference. This post does not print a price.
Create the key in Console · API Keys. Every request uses Authorization: Bearer plus that key. A job can be queried only with the key that created it.
The docs describe three modes. The synchronous endpoints POST /v1/images/generations and POST /v1/videos/generations wait until generation finishes. Async polling is POST /api/v1/jobs/createTask, then GET /api/v1/jobs/recordInfo?taskId=.... A callback is optional: pass callBackUrl and callbackSecret at create time. This script uses polling only.
The docs also say: native parameters for an async job go inside input. The same fields on the synchronous gateway stay at the top level or inside params. Chat is not on the jobs protocol. An unsupported model returns HTTP 400 and is not charged. JSON bodies are limited to 1 MB. Create and query together are limited to 120 requests per key per minute.
The image example on the async page is seedream/5-pro-text-to-image, with prompt, aspect_ratio, and quality inside input. The video example on the gateway page is kling/v3-turbo-text-to-video, with prompt, duration, and resolution. The script puts those video fields inside input, which is what the async page says to do.
import os
import time
import requests
API = "https://modelfold.ai"
HEADERS = {
"Authorization": f"Bearer {os.environ['MODELFOLD_API_KEY']}",
"Content-Type": "application/json",
}
def create_task(model, input_payload, idempotency_key):
response = requests.post(
f"{API}/api/v1/jobs/createTask",
headers={**HEADERS, "Idempotency-Key": idempotency_key},
json={"model": model, "input": input_payload},
timeout=60,
)
response.raise_for_status()
body = response.json()
# Documented create response: {"code":200,"msg":"success","data":{"taskId","state":"queued","reused":false}}
return body["data"]["taskId"]
def poll(task_id, attempts=60, pause_seconds=10):
for _ in range(attempts):
response = requests.get(
f"{API}/api/v1/jobs/recordInfo",
headers=HEADERS,
params={"taskId": task_id},
timeout=60,
)
response.raise_for_status()
data = response.json()["data"]
state = data["state"]
# queued, submitting, processing, uncertain, success, fail
if state == "success":
return data["resultJson"]
if state == "fail":
raise RuntimeError(data.get("failMsg"))
if state == "uncertain":
raise RuntimeError(f"uncertain, contact support with taskId {task_id}")
time.sleep(pause_seconds)
raise TimeoutError(task_id)
image_id = create_task(
"seedream/5-pro-text-to-image",
{"prompt": "a paper boat in the rain", "aspect_ratio": "1:1", "quality": "basic"},
"image-20261126-001",
)
video_id = create_task(
"kling/v3-turbo-text-to-video",
{"prompt": "a paper boat in the rain", "duration": "3", "resolution": "720p"},
"video-20261126-001",
)
print(poll(image_id))
print(poll(video_id))
The documented create response is code 200, msg success, and data.taskId with state queued. The docs say a repeated Idempotency-Key with the same body returns the original task and does not charge again. The same key with a different body returns 409. The key is 1–200 characters.
resultJson on success is a JSON string. The sample in the docs looks like {"resultUrls":["https://modelfold.ai/uploads/outputs/result.png"]}. Parse that string to read the URL. fail puts the message in failMsg. uncertain means the submit result is unknown: the docs say not to place the order again, and to contact support with the taskId if it stays that way.
The gateway page says a long synchronous video should use a client timeout of at least 20 minutes. Polling avoids holding that connection. A failed generation is not charged; the product page states that failed calls are not billed. Confirm the current rule on modelfold.ai before you rely on it for a budget.
If you also want to see whether ChatGPT or Perplexity recommends a brand, that is a separate free check at ModelFold GEO. I work on that product too.
Top comments (0)