> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.meshapi.ai/llms.txt.
> For full documentation content, see https://developers.meshapi.ai/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.meshapi.ai/_mcp/server.

# Embeddings

> Create dense vector embeddings with the Mesh API and the official SDKs.

The Embeddings API turns text into vectors you can use for semantic search, retrieval, clustering, and ranking.

```http
POST https://api.meshapi.ai/v1/embeddings
Authorization: Bearer rsk_<your_key>
```

## Quick start

```bash
curl https://api.meshapi.ai/v1/embeddings \
  -H "Authorization: Bearer <YOUR_RSK_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/text-embedding-3-small",
    "input": "The quick brown fox jumps over the lazy dog."
  }'
```

```ts
import { MeshAPI } from "meshapi-node-sdk";

const client = new MeshAPI({
  baseUrl: "https://api.meshapi.ai",
  token: process.env.MESH_API_KEY!,
});

const response = await client.embeddings.create({
  model: "openai/text-embedding-3-small",
  input: "The quick brown fox jumps over the lazy dog.",
});

console.log(response.data[0]?.embedding);
```

```python
from meshapi import EmbeddingsParams, MeshAPI

client = MeshAPI(
    base_url="https://api.meshapi.ai",
    token="rsk_...",
)

response = client.embeddings.create(
    EmbeddingsParams(
        model="openai/text-embedding-3-small",
        input="The quick brown fox jumps over the lazy dog.",
    )
)

print(response.data[0].embedding)
```

## Request fields

| Field             | Type                                       | Notes                                                             |
| ----------------- | ------------------------------------------ | ----------------------------------------------------------------- |
| `model`           | string                                     | Embedding model ID. Required unless your key has a default model. |
| `input`           | string \| string\[] \| int\[] \| int\[]\[] | Text or tokenized input.                                          |
| `dimensions`      | integer                                    | Optional output size for models that support truncation.          |
| `encoding_format` | `"float"` \| `"base64"`                    | Output format.                                                    |
| `input_type`      | string                                     | Optional hint for asymmetric embedding models.                    |
| `provider`        | string \| object                           | Optional provider routing preferences.                            |
| `user`            | string                                     | Optional end-user identifier for abuse monitoring.                |

## Batch input in a single request

You can embed multiple strings in one API call:

```bash
curl https://api.meshapi.ai/v1/embeddings \
  -H "Authorization: Bearer <YOUR_RSK_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/text-embedding-3-small",
    "input": [
      "first sentence",
      "second sentence",
      "third sentence"
    ]
  }'
```

The returned `data` array matches the order of your input array.

## Response shape

```json
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [-0.0123, 0.0456]
    }
  ],
  "model": "openai/text-embedding-3-small",
  "usage": {
    "prompt_tokens": 12,
    "total_tokens": 12
  }
}
```

## Choosing a model

Use `GET /v1/models` to inspect available embedding models and their pricing. For embeddings, the most useful fields are:

* `model_type`
* `context_length`
* `pricing`
* `is_free`

## SDK coverage

The official SDKs all expose first-class embeddings resources:

* Node: `client.embeddings.create(...)`
* Python: `client.embeddings.create(...)`
* Go: `client.Embeddings.Create(...)`
* Java: `client.embeddings().create(...)`

## Common errors

| HTTP  | Meaning                      |
| ----- | ---------------------------- |
| `401` | Missing or invalid API key   |
| `402` | Balance or spend limit issue |
| `422` | Invalid request body         |
| `429` | Rate limit exceeded          |