Decisions

Images in a state

tod picker is multimodal. Send images inline with the request.

Forms

Images travel inline in the JSON body, in either form:

  • a data URL: {"image": "data:image/png;base64,…"}
  • raw base64: {"image_b64": "…"}

Put image segments anywhere in a state list to interleave them with text, or pass them in images to append them after the state.

Limits

  • PNG, JPEG, WebP and GIF. The type is read from the bytes, not the data URL.
  • Up to 5 MB per image, decoded, and up to 8 images per request.
  • File paths and http(s) URLs are not fetched.
  • Images count toward input tokens like text.

A malformed, oversized, or unsupported image is refused with 422 bad_image and not billed.

Example

import base64, os, requests

def data_url(path):
    mime = "image/png" if path.endswith(".png") else "image/jpeg"
    return f"data:{mime};base64," + base64.b64encode(open(path, "rb").read()).decode()

r = requests.post(
    "https://platform.parseclab.ai/v1/systemone",
    headers={"Authorization": f"Bearer {os.environ['PARSEC_API_KEY']}"},
    json={
        "state": [
            {"text": "Customer says the parcel arrived like this:"},
            {"image": data_url("parcel.jpg")},
        ],
        "questions": {
            "damaged": {"type": "noul", "criteria": {"true": "Visibly damaged", "false": "Intact"}},
        },
    },
    timeout=60,
)
print(r.json()["answers"]["damaged"]["noul"])