SERVICE
Image recognition API
Send one image and an optional question with a single paid HTTP call, and receive the answer as plain text or Markdown.
Overview
One POST sends one image, either as an image URL or as one Base64 string, with an optional prompt. A local file can be sent directly as Base64, with no separate upload. The response carries the answer in the format you choose.
Anonymous calls pay with x402 on Base, so no account or API key is needed. The payment flow and the rules shared by every service are in the platform documentation.
POST https://api.koinelix.com/v1/images/recognitionsQuickstart
Use curl to get a quote. After reviewing it, use the TypeScript or Python example to make a paid call.
example.com image URLs are placeholders showing the URL format. Replace them with an accessible image URL before making an actual call.
New to x402? Start with the preparation guide →# example.com is a placeholder. Replace it with an accessible image URL before calling.
# 1. Ask for a quote. No payment, no account.
curl -i -X POST https://api.koinelix.com/v1/images/recognitions \
-H 'Content-Type: application/json' \
-d '{"image_url":"https://example.com/photo.jpg","prompt":"What is in this image?","output_format":"markdown"}'
# HTTP/2 402
# PAYMENT-REQUIRED: <base64 x402 v2 quote: price, network, asset, payee>
#
# 2. An x402 client signs that quote with your wallet and repeats the same request
# with a PAYMENT-SIGNATURE header. See the TypeScript and Python tabs.- Manage wallet secrets only in your own execution environment. Never paste private keys or seed phrases into this website.
- Set the client timeout to at least 120 seconds and keep the connection open until the response arrives.
- If the connection drops or times out, send the same request again with the same PAYMENT-SIGNATURE instead of paying again.
Call with an API key
With a platform API key the call uses your account quota first, and an x402 quote is returned only when none is left.
API key calls use your account quota. Registration and key creation do not grant quota.
# image_b64 is ONE standard Base64 string without a data: prefix (not an array).
# A photo is too big for a command-line argument, so the body goes through a file.
IMAGE_B64=$(base64 < photo.png | tr -d '\n')
printf '{"image_b64":"%s","prompt":"List the items on this receipt","output_format":"markdown"}' "$IMAGE_B64" > body.json
curl -sS -X POST https://api.koinelix.com/v1/images/recognitions \
-H "Authorization: Bearer $KOINELIX_API_KEY" \
-H 'Content-Type: application/json' \
--max-time 120 \
--data-binary @body.json- Send the key as Authorization: Bearer <your API key>. Idempotency-Key is optional.
- Repeating a request with the same Idempotency-Key and body returns the original request instead of starting a new call.
Request body
Send a JSON body with Content-Type: application/json. Provide exactly one of image_url and image_b64.
| Field | Type | Required | Description |
|---|---|---|---|
image_url | string | One of the two | Absolute http or https URL of the image, up to 2048 characters. |
image_b64 | string | One of the two | The image as one standard padded Base64 string on a single line, without a data: prefix: png, jpeg, webp or gif, up to 10 MiB decoded. It is a single string, not an array. Produce it in code and put it into the request body (for example base64 < photo.png | tr -d "\n"); images up to the limit work this way. A client that writes tool-call arguments by hand, token by token, can easily corrupt a long string: it should use image_url, let code build the request, or send a small thumbnail. |
prompt | string | No | What you want to know about the image, up to 4000 UTF-8 bytes. A default description request is used when omitted. |
output_format | "text" | "markdown" | No | The format of the answer: text (default) or markdown. |
Example request body
{
"image_url": "https://example.com/photo.jpg",
"prompt": "What is in this image?",
"output_format": "markdown"
}Response
A successful call returns HTTP 200 with a JSON body.
| Field | Type | Description |
|---|---|---|
id | string | Identifier of the call. |
created | integer | Unix time in seconds. |
format | "text" | "markdown" | The format of this answer. |
content | string | null | The answer. null when the same request is resent after the answer was delivered. |
truncated | boolean | true when the answer was cut to the size limit. |
{
"id": "c_0123456789abcdef",
"created": 1767225600,
"format": "markdown",
"content": "A tabby cat sitting on a wooden windowsill.",
"truncated": false
}PAYMENT-RESPONSE carries the x402 settlement when you paid.
Errors
Errors use the same JSON error body as every Koinelix API. Shared payment and request errors are listed in the platform documentation.
| HTTP | Code | What to do |
|---|---|---|
| 400 | validation_failed | The request body is invalid; error.param names the field. Fix it and send again. |
| 409 | request_in_progress | The original request with this key or signature is still running. Wait, then send it again. |
| 422 | upstream_rejected | The image or the prompt could not be processed. Check that the image is readable and the prompt is valid. |
| 502 | recognition_failed | The recognition request failed. Try again later. |
| 502 | recognition_empty | The model returned no answer. Try a different image or prompt. |
| 502 | recognition_not_started | The request could not be sent. Try again later. |
| 503 | capacity_unavailable | No capacity is available right now. Try again shortly. |
| 503 | service_not_configured | The service is not open yet. |
| 504 | recognition_timeout | The request timed out. Try again later. |