Skip to main content
POST
Image Detection
The Image API accepts one base64-encoded image and returns a task ID. Poll that task for its result. Use the model field to choose an image detection model.

Choose a model

Pass a model selector to choose a model series, or use default to follow the service default. pangram-image-1 selects the Image 1 series. Minor versions within the series can change without changing the selector. The response’s version field reports the model version used; it is null when validated provenance determines the result without model inference. Model versions are independent of the API route and Python package versions. The text Models API and Pangram.list_models() describe text models; they do not list image models.

Base URL and authentication

Send your API key in the x-api-key header on submission and polling. Read a task with the same key that created it.
Native image methods require Python SDK 1.1.0 or later. Choose the model explicitly with predict_image(); list_models() lists text models.

Python SDK

The SDK accepts a file path, raw bytes, or an open binary file and handles base64 encoding and polling. model is required; use a selector from the table above, or default to follow the service default. For separate submission and polling, use submit_image(), get_image_status(), and wait_for_image(). See the SDK reference.

POST /v1/tasks

Submit one image as JSON.
string
required
Base64-encoded image bytes, either plain base64 or a base64 data URL. The decoded image can be at most 32 MiB, and the complete JSON request body can be at most 128 MiB.
string
default:"default"
Image model selector from the table above. Use default to follow the service default.
Unknown request fields are rejected. This endpoint accepts one image per task and does not expose a bulk-image operation.

cURL

Python REST

Successful admission returns 202 Accepted:

GET /v1/tasks/

An in-progress response contains the task ID and its current stage:
Processing stages are STAGE_IMAGE_INFERENCE and STAGE_IMAGE_FINALIZING. Terminal stages are STAGE_SUCCESS and STAGE_FAILED.

Poll with Python

Continue from the submission example:

Success response

Provenance-only results can have null model scores, confidence, version, and heatmap. Clients should handle those nullable fields.

Failed tasks and request errors

A failed task is returned by the polling endpoint with HTTP 200 and stage: "STAGE_FAILED". Check the stage as well as the HTTP status.
Immediate request errors return the same nested error object without a task ID or stage. An accepted image that cannot be decoded can fail asynchronously.

Billing and retries

A successful task bills one image at your account’s image API rate. Failed tasks are not billed. See the pricing page for current rates. Keep the accepted task_id and continue polling it after a client-side timeout. Image submission does not accept an idempotency key: submitting the image again creates another task and can incur another charge.