Skip to content
Docs version r8
OpenAPIJSONYAML
Guides / Interrupted submissions

Interrupted submissions

Each accepted create is its own task with its own charge. When a create times out, find out what happened before you send it again.

Markdown fileTry in PlaygroundDocs version r8

Send a create once

Every create that the API accepts makes a new task, holds Credits for it and may charge for it, even when the body is identical to an earlier one. Turn off automatic retries for POST /v1/generations in your HTTP client, SDK wrapper and any proxy in between.

Give every create a metadata.client_reference of your own, such as your order ID. It is how you find the task when the response is lost.

What you may retry

What happenedWas a task created?What to do
HTTP 202YesSave the id. Never resend.
HTTP 4xx other than 429NoFix the request. Resending it unchanged gets the same error.
HTTP 429NoWait Retry-After seconds and send it again.
HTTP 500 or 503PossiblyLook first, as below.
Timeout or dropped connectionPossiblyLook first, as below.

Look before you resend

  1. If you have the task id, read it with get a generation.
  2. Otherwise, list tasks with list generations, filtered by your client_reference.
  3. Only if no task matches, send the create again.

cURL

curl "https://api.vizoapi.com/v1/generations?client_reference=order-1042" \
  -H "Authorization: Bearer $VIZO_API_KEY" \
  | jq '.entries[] | {id, status, created_at}'

Python

import os, requests

def find(reference):
    res = requests.get(
        "https://api.vizoapi.com/v1/generations",
        headers={"Authorization": f"Bearer {os.environ['VIZO_API_KEY']}"},
        params={"client_reference": reference},
        timeout=30,
    ).json()
    return res["entries"][0] if res["entries"] else None

The list is newest first and can be narrowed further with model, status, created_after (inclusive) and created_before (exclusive). Listing needs the generations:list scope.

Note

A task found this way is the one you created: keep polling it. A second create would make a second task and a second charge.