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

# Embeddings API

> Generate vector embeddings for search, retrieval, and clustering workflows.

Use the `Embeddings API` when you need numeric vector representations of text for semantic search, retrieval, ranking, recommendation, or clustering.

If you need generated text, tools, or multimodal conversation flows, use `Responses API` instead.

## Best Fit

* RAG indexing pipelines
* semantic search over documents or tickets
* clustering or classification workflows

## Request Model

Most requests need:

* `model`
* `input`
* optionally `dimensions`
* optionally `encoding_format`

The response contains one or more embedding vectors plus token usage metadata. NagaAI supports both JSON float vectors and base64-encoded vectors for transport efficiency.

## Quick Example

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(base_url="https://api.naga.ac/v1", api_key="YOUR_API_KEY")

  response = client.embeddings.create(
      model="text-embedding-3-small",
      input=["vector search", "semantic retrieval"]
  )

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

  ```javascript Node.js theme={null}
  import OpenAI from 'openai';

  const client = new OpenAI({
    baseURL: 'https://api.naga.ac/v1',
    apiKey: 'YOUR_API_KEY',
  });

  const response = await client.embeddings.create({
    model: 'text-embedding-3-small',
    input: ['vector search', 'semantic retrieval'],
  });

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

  ```bash cURL theme={null}
  curl https://api.naga.ac/v1/embeddings \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "text-embedding-3-small",
      "input": ["vector search", "semantic retrieval"]
    }'
  ```
</CodeGroup>

## Response Anatomy

```json theme={null}
{
  "object": "list",
  "model": "text-embedding-3-small",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [0.12, -0.03, 0.41]
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "total_tokens": 12
  }
}
```

The `usage` object contains `prompt_tokens` and `total_tokens`. Because embeddings do not generate new text, there are no completion tokens to bill for.

## Common patterns

* embed one query string for retrieval at request time
* embed batches of document chunks during indexing
* lower transport size with `encoding_format="base64"` when needed
* request `dimensions` only if your selected model supports it and your vector store expects it

## What To Learn Next

* [Batch Inputs](/api/embeddings/batch-inputs)
* [Output Formats](/api/embeddings/output-formats)
* [Retrieval Patterns](/api/embeddings/retrieval-patterns)

## Related Docs

* [Models](/get-started/models)
* [Rate Limits](/build/rate-limits)

## Reference

* [Create embeddings](/api-reference/endpoints/embeddings/create)
