Inference API

Embeddings

View as Markdown

Create embeddings

/v1/embeddings

Create an embedding vector representation corresponding to the input text. This is the endpoint for making requests to embedding models.

Request Body

Response Body

dataarray<object>

A list of embedding objects.

modelstring

Model ID used to create embedding.

objectstring

The object type of `data` field, which is always `"list"`.

Exampletext

text

"{\n            \"input\": [\"This is an example content to embed...\"],\n            \"model\": \"v1\",\n            \"encoding_format\": \"float\"\n        }"
Exampletext

text

{
  "object": "list",
  "model": "v1",
  "data": [
    {
      "index": 0,
      "embedding": [
        0.01567895,
        0.063257694,
        0.045925662
      ],
      "object": "embedding"
    }
  ],
  "usage": {
    "prompt_tokens": 1,
    "total_tokens": 1
  }
}

List embedding models

/v1/embedding-models

List all embedding models available to the authenticating API key with full information. Additional information compared to /v1/models includes modalities, fingerprint and alias(es).

Response Body

modelsarray<object>

Array of available embedding models.

Exampletext

text

No parameters.
Exampletext

text

{
  "models": [
    {
      "id": "v1",
      "fingerprint": "fp_df37966059",
      "created": 1725148800,
      "object": "model",
      "owned_by": "xai",
      "version": "0.1.0",
      "input_modalities": [
        "text"
      ],
      "prompt_text_token_price": 100,
      "prompt_image_token_price": 0,
      "aliases": []
    }
  ]
}

Get embedding model

/v1/embedding-models/{model_id}

Get full information about an embedding model with its model_id.

Path Parameters

model_idstring

ID of the model to get.

Response Body

aliasesarray<string>

Alias ID(s) of the model that user can use in a request's model field.

createdinteger

Model creation time in Unix timestamp.

fingerprintstring

Fingerprint of the xAI system configuration hosting the model.

input_modalitiesarray<string>

The input modalities supported by the model.

objectstring

Object type, should be model.

output_modalitiesarray<string>

The output modalities supported by the model.

owned_bystring

Owner of the model.

prompt_image_token_priceinteger

Price of the prompt image token in USD cents per million token.

prompt_text_token_priceinteger

Price of the prompt text token in USD cents per million token.

versionstring

Version of the model.

Exampletext

text

No parameters.
Exampletext

text

{
  "id": "v1",
  "created": 1725148800,
  "object": "model",
  "owned_by": "xai",
  "version": "0.1.0",
  "input_modalities": [
    "text"
  ],
  "prompt_text_token_price": 10,
  "prompt_image_token_price": 0,
  "aliases": []
}