Image Classification
POST
https://api.oneinfer.ai/v1/ula/classify-imageScore how well each label you name describes an image, with no training (zero-shot), using OpenAI's CLIP models.
Request headers
AuthorizationstringrequiredBearer token for authentication. Format:
Bearer <YOUR_TOKEN>. Exchange your API key for a token via the Authentication endpoint.Content-Typestringrequiredapplication/json
Request parameters
modelstringrequiredopenai/clip-vit-base-patch32 or openai/clip-vit-large-patch14-336.imagestringrequiredThe image: a public
https URL, or a data:image/...;base64, URL.labelsstring[]requiredThe labels to score: 2 to 100 distinct, non-empty strings.
Good to know
- Results come best first, one per label, each with its
score. - You pay per second of compute, not per image: a call takes 30–70 ms when the model is warm and a second or more when it isn't.
usage.billed_secondsis the time charged.
Example request
POST {BASE_URL}/v1/ula/classify-image
{
"model": "openai/clip-vit-base-patch32",
"image": "https://oneinfer.ai/assets/docs/classify-image-example.jpg",
"labels": [
"a circuit board",
"a cat",
"a car"
]
}Response
JSON
200 OK
{
"model": "openai/clip-vit-base-patch32",
"results": [
{
"label": "a circuit board",
"score": 0.99993
},
{
"label": "a car",
"score": 0.000065
},
{
"label": "a cat",
"score": 0.0000062
}
],
"usage": {
"billed_seconds": 0.063,
"credits_used": 0.003465
}
}Error status codes
| Code | Status | Description |
|---|---|---|
200 | OK | The reply is ready; usage.credits_used is what was charged. |
400 | Bad Request | The model isn't an image classification model, or the image isn't a public https URL or a data:image URL. |
401 | Unauthorized | Missing or invalid Authorization header / Bearer token. |
403 | Forbidden | Your account balance is too low. |
422 | Unprocessable Entity | The request body failed validation, for example an empty or missing field. |
502 | Bad Gateway | The provider serving the model failed. Try again later. |
503 | Service Unavailable | The model is busy or unavailable. Retry after a short wait. |