Skip to main content

Embeddings

Generate high-quality vector embeddings for text using the Gravix Layer API. This endpoint is compatible with OpenAI's embedding API and supports seamless integration in Python and JavaScript.


Quickstart

Get started by calling the embeddings endpoint with your API key and model of choice.

Endpoint

POST /v1/inference/embeddings

Request Headers

Content-Type: "application/json"
Authorization: Bearer GRAVIXLAYER_API_KEY

Example Usage

curl https://api.gravixlayer.com/v1/inference/embeddings \
-H "Authorization: Bearer $GRAVIXLAYER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "Why is the sky blue?",
"model": "meta-llama/llama-3.1-8b-instruct"
}'

Response

The API returns a JSON response with the following structure:

{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [
0.0023064255,
-0.009327292,
-0.0028842222,
"... (1536 floats total for text-embedding-ada-002)"
],
"index": 0
}
],
"model": "meta-llama/llama-3.1-8b-instruct",
"usage": {
"prompt_tokens": 5,
"total_tokens": 5
}
}