Image Classification

POSThttps://api.oneinfer.ai/v1/ula/classify-image

Score how well each label you name describes an image, with no training (zero-shot), using OpenAI's CLIP models.

Request headers

Authorizationstringrequired
Bearer token for authentication. Format: Bearer <YOUR_TOKEN>. Exchange your API key for a token via the Authentication endpoint.
Content-Typestringrequired
application/json

Request parameters

modelstringrequired
openai/clip-vit-base-patch32 or openai/clip-vit-large-patch14-336.
imagestringrequired
The image: a public https URL, or a data:image/...;base64, URL.
labelsstring[]required
The 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_seconds is 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

CodeStatusDescription
200OKThe reply is ready; usage.credits_used is what was charged.
400Bad RequestThe model isn't an image classification model, or the image isn't a public https URL or a data:image URL.
401UnauthorizedMissing or invalid Authorization header / Bearer token.
403ForbiddenYour account balance is too low.
422Unprocessable EntityThe request body failed validation, for example an empty or missing field.
502Bad GatewayThe provider serving the model failed. Try again later.
503Service UnavailableThe model is busy or unavailable. Retry after a short wait.

Response

202 - application/json