Skip to content

POST /image-analysis

Send a photo and a question. RebelCore™ returns a written answer and the regions of the photo it’s concerned about, so your application can draw them over the photo.

"Does this radiator look like it's leaking or are the fins damaged?"
↓
Answer: "The fins are visibly bent across the centre..."
Regions: Bent fins, medium severity, at x 0.25, y 0.21, width 0.51, height 0.67

There are two endpoints, which work the same way:

EndpointUse it for
POST /api/v1/image-analysisOne photo. The usual case.
POST /api/v1/image-analysis/batchUp to five photos with one question.

Before you start

  • A bearer token. From /authorize (API user) or /authorize/totp (standard user). Either works.
  • Your organisation’s permission. Photos can’t be masked, so a photo reaches the AI model as it is, including any faces, number plates or documents in it. If your organisation’s settings don’t allow unmasked data to be sent to AI, these endpoints return 403 image_analysis_not_allowed.

Photos may be processed outside your data residency region.

Request

Send multipart/form-data, with your token in the Authorization: Bearer <token> header.

FieldTypeRequiredNotes
imagefileyes, on /image-analysisOne JPEG, PNG or WebP photo.
imagesfile, repeatedyes, on /image-analysis/batchUp to five photos.
querytextyesYour question, up to 1,000 characters.

The whole request can be up to 25 MB. Each photo needs to be at least 32 pixels on its shortest side, and HEIC isn’t supported, so convert those first.

For a batch, shrink photos to around 2048 pixels on the long side before sending. That’s the size they’re analysed at anyway, and it saves upload time.

Response

200 OK. A response from /image-analysis:

{
"analysis_id": "7f3c1e0a9b2d4c6e8f10a2b3c4d5e6f7",
"correlation_id": "api:4b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e",
"status": "completed",
"answer": "The fins are visibly bent across the centre, which can restrict airflow. The photo doesn't show clear wetness, so a leak can't be confirmed.",
"regions": [
{
"id": "r1",
"label": "Bent and crushed fins",
"severity": "medium",
"certainty": "high",
"explanation": "A broad central section has warped, folded fins.",
"box": { "x": 0.25, "y": 0.21, "w": 0.51, "h": 0.67 }
}
],
"image": { "width": 605, "height": 330 },
"notice": "AI-generated visual assessment, not a professional inspection."
}
FieldNotes
statuscompleted, or cannot_assess if the photo is too blurry or dark, or doesn’t show what you asked about. answer then explains why.
answerThe written answer.
regionsAreas of concern, at most 10. Empty means nothing was found, or that the photo couldn’t be assessed.
regions[].severitylow, medium or high: how much the problem matters.
regions[].certaintylow, medium or high: how sure the analysis is that it’s a real problem.
regions[].boxWhere to draw it. See below.
imageThe size of the photo as analysed. It’s reduced to at most 2048 pixels on the long side.
noticeShow this to your users alongside the results.
analysis_idIdentifies this analysis in the audit. Log it with your own records.

Drawing the regions

x and y are the top-left corner, and w and h the size, all as fractions of the photo’s width and height, from 0 to 1. Multiply by the size you display the photo at, and they fit at any size:

const left = box.x * displayedWidth;
const top = box.y * displayedHeight;
const width = box.w * displayedWidth;
const height = box.h * displayedHeight;

Coordinates refer to the upright photo. Phone cameras often store a photo sideways with a rotation tag, so display it with that rotation applied (most image libraries do this by default), or the boxes won’t line up.

Batch response

/image-analysis/batch returns one item per photo, in the order you sent them, each with an index:

{
"correlation_id": "api:4b1d2c3e4f5a6b7c8d9e0f1a2b3c4d5e",
"items": [
{ "index": 0, "status": "completed", "analysis_id": "…", "answer": "…", "regions": [], "image": {}, "notice": "…" },
{ "index": 1, "status": "failed", "analysis_id": "…", "error": { "code": "invalid_image", "message": "…" } }
]
}

The call returns 200 once it starts running, even if some photos fail, so check each item’s status. Allow around a minute for five photos.

Errors

On /image-analysis, or for the whole request on /batch, the code is in detail.code:

StatusCodeWhen
401Missing, expired or invalid token, or a standard user who’s been deactivated.
403image_analysis_not_allowedYour organisation doesn’t allow unmasked data to be sent to AI.
403image_analysis_disabledPhoto analysis is turned off.
413request_too_largeThe request is over 25 MB.
413image_too_largeThe photo has more than 50 million pixels.
415invalid_imageThe file isn’t a readable JPEG, PNG or WebP.
422image_too_smallThe photo is under 32 pixels on a side.
422too_many_photosMore than five photos on /batch.
422query_requiredThe question is blank.
429image_analysis_limit_reachedThe daily limit is reached: 50 photos per user per day, counted in UTC. A batch of five counts as five. See the Retry-After header.
502image_analysis_failedThe analysis failed. Try again.

Audit and retention

Each analysis is recorded in your organisation’s audit and doesn’t create a chat session. A Customer Super Admin can review it under Audit → Photo analyses, including the photo and its regions.

Photos are stored in your organisation’s own storage and kept indefinitely. GPS and all other photo metadata are removed first, and the stored copy is the reduced, upright version.

Example

curl

Terminal window
curl https://api.rebelcore.ai/api/v1/image-analysis \
-H "Authorization: Bearer $TOKEN" \
-F "image=@radiator.jpg" \
-F "query=Are the fins damaged? Identify problem areas."

Python (httpx)

import httpx
with open("radiator.jpg", "rb") as photo:
r = httpx.post(
"https://api.rebelcore.ai/api/v1/image-analysis",
headers={"Authorization": f"Bearer {token}"},
files={"image": ("radiator.jpg", photo, "image/jpeg")},
data={"query": "Are the fins damaged? Identify problem areas."},
timeout=90.0,
)
r.raise_for_status()
result = r.json()
print(result["answer"])
for region in result["regions"]:
print(region["label"], region["severity"], region["box"])

Python, up to five photos

names = ["front.jpg", "left.jpg", "right.jpg"]
files = [("images", (name, open(name, "rb"), "image/jpeg")) for name in names]
r = httpx.post(
"https://api.rebelcore.ai/api/v1/image-analysis/batch",
headers={"Authorization": f"Bearer {token}"},
files=files,
data={"query": "Are the fins damaged? Identify problem areas."},
timeout=120.0,
)
r.raise_for_status()
for item in r.json()["items"]:
if item["status"] == "failed":
print(names[item["index"]], "failed:", item["error"]["code"])
else:
print(names[item["index"]], item["answer"])