Documentation

API Reference
POST

Embeddings

/v1/embeddings

Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.

Interactive Example

Request & Response Example

curl https://api.a4f.co/v1/embeddings \
-H "Authorization: Bearer YOUR_A4F_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "provider-2/text-embedding-3-small",
"input": "The quick brown fox jumps over the lazy dog"
}'

Headers

Authorization

string
Required
Bearer token for authentication. Your A4F API key.

Request Body

model

string
Required
ID of the embedding model to use. Must be a model of type embeddings.

input

string or array of strings
Required
The input text or texts to embed.

encoding_format

string
The format to return the embeddings in. Can be either float or base64.

Default: float

dimensions

integer
The number of dimensions the resulting output embeddings should have. Only supported by certain models. Requesting an unsupported dimension will result in an error.

user

string
A unique identifier representing your end-user, for monitoring and abuse detection.

Response Body (200 OK)

object

string
The object type, which is always 'list'.

data

array of objects
A list of embedding objects.

object

string
The object type, which is always 'embedding'.

embedding

array of numbers or string
The embedding vector, which is a list of floats or a base64 encoded string.

index

integer
The index of the embedding in the list.

model

string
The model ID used for the embedding.

usage

object
Usage statistics for the request.

prompt_tokens

integer
The number of tokens in the input.

total_tokens

integer
The total number of tokens consumed by the request.

Was this page helpful?