> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tokmodel.com/llms.txt
> Use this file to discover all available pages before exploring further.

# POST /v1/embeddings — Text Embeddings

> Generate vector embeddings for one or more text inputs. Use embeddings for semantic search, clustering, classification, and retrieval-augmented generation.

The `/v1/embeddings` endpoint converts text into numerical vector representations (embeddings). You can pass a single string or a batch of strings in one request. The resulting vectors can be stored in a vector database and used for semantic search, document clustering, classification, or as input to a retrieval-augmented generation (RAG) pipeline. This endpoint is compatible with the OpenAI embeddings format.

## Request parameters

<ParamField body="model" type="string" required>
  The embedding model to use. Use the [list models](/api-reference/models) endpoint to find available embedding model IDs.
</ParamField>

<ParamField body="input" type="string | string[]" required>
  The text to embed. Pass a single string or an array of strings to embed multiple inputs in one request. Token limits vary by model.
</ParamField>

<ParamField body="encoding_format" type="string" default="float">
  The format in which to return the embedding vectors. Use `"float"` for an array of floating-point numbers, or `"base64"` for a Base64-encoded string.
</ParamField>

## Response fields

<ResponseField name="object" type="string">
  Always `"list"`.
</ResponseField>

<ResponseField name="data" type="array">
  An array of embedding objects, one for each input string. Objects are returned in the same order as the input.

  <Expandable title="properties">
    <ResponseField name="object" type="string">
      Always `"embedding"`.
    </ResponseField>

    <ResponseField name="index" type="integer">
      Zero-based position of this embedding in the input array.
    </ResponseField>

    <ResponseField name="embedding" type="number[]">
      The embedding vector as an array of floats (or a Base64 string if `encoding_format` is `"base64"`). The dimensionality depends on the model.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="model" type="string">
  The model used to generate the embeddings.
</ResponseField>

<ResponseField name="usage" type="object">
  Token usage for the request.

  <Expandable title="properties">
    <ResponseField name="prompt_tokens" type="integer">
      Number of tokens in the input text(s).
    </ResponseField>

    <ResponseField name="total_tokens" type="integer">
      Total tokens consumed. Equal to `prompt_tokens` for embedding requests.
    </ResponseField>
  </Expandable>
</ResponseField>

## Example

### Request

```bash theme={null}
curl https://tokmodel.com/v1/embeddings \
  --request POST \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "openai/text-embedding-3-small",
    "input": ["TokModel is a unified LLM gateway.", "It supports 30+ AI providers."],
    "encoding_format": "float"
  }'
```

### Response

```json theme={null}
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [0.0023, -0.0091, 0.0412, -0.0188, "..."]
    },
    {
      "object": "embedding",
      "index": 1,
      "embedding": [0.0071, -0.0033, 0.0299, -0.0144, "..."]
    }
  ],
  "model": "openai/text-embedding-3-small",
  "usage": {
    "prompt_tokens": 16,
    "total_tokens": 16
  }
}
```
