Image Embedding LLM API Endpoint

Version 2.197 (Release Notes ↗)

Description

The Image Embedding API endpoint leverages cutting-edge vision models to generate numerical image representations. This results in high-dimensional embedding vectors that encapsulate the semantic content of the images. Developers can submit Base64 encoded image via this API and receive corresponding embeddings. This functionality empowers developers to implement image-based similarity searches, image classification, and content-based image retrieval. By utilizing pre-trained models, the API abstracts away the complexities of image processing, allowing developers to harness the power of deep learning for various applications without the overhead of model training.

HTTP Methods

JSON POST

HTTP Parameters

Required

Fields Type Description
img BASE64 String BASE 64 encoded string representing the image contents you want to generate an image embedding vector for.
key String Your PixLab API Key ↗. You can also embed your key in the WWW-Authenticate: HTTP header and omit this parameter if you want to.

Optional

Fields Type Description
dimension integer The output embedding vector dimension. The value must be either 512 or 1024. Defaults to 512.

POST Request Body

This section outlines the requirements for POST requests, which are used instead of GET requests in specific scenarios.

Allowed Content-Types:

  • application/json

JSON is the default format for POST requests. If you are uploading a file via a JSON POST request, please ensure the file is base64 encoded within the JSON payload.

HTTP Response

application/json

The default response format is the PixLab simple LLM response format which is unified across our vLM API endpoints, and is suitable for most applications that includes the bare minimum information including the embedding vector, tokens count, etc.

PixLab Simple vLM Response Format


{
  "status": 200,
  "id": "6783E34342",
  "embedding": [2.8765, 1.9870, 4.9076, 7.9177, ...],
  "object": "embedding",
  "created": 1694623155,
  "model": "pix-llm",
  "total_input_tokens": 25,
  "total_output_tokens": 57,
}
Fields Type Description
status Integer HTTP 200 indicates success. Any other code indicates failure.
id Integer random ID to identify the generated response output.
embedding List An array (or list) of floating points stream containing the complete output image embedding vector.
object String Invoked vLM API endpoint.
created Timestamp Timestamp of generated output creation.
model String Underlying LLM model ID/Name.
total_input_tokens Integer total number of ingested tokens.
total_output_tokens Integer Total number of output tokens.
error String Error description when status != 200.

Code Samples


# For a comprehensive list of production-ready code samples, please consult the PixLab Github Repository: https://github.com/symisc/pixlab.

← Return to API Endpoint Listing