Skip to main content
The input field can be a single string or an array of inputs. Batching is useful when you are indexing many chunks and want to reduce request overhead.

Batch Example

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=["semantic search", "vector database", "hybrid retrieval"],
)

print(response.data[0].index)
The response returns one embedding per input with an index field, so you can map results back to the original batch order.

How to read the result

  • data[0] is the embedding for the first input
  • data[1] is the embedding for the second input
  • the index field lets you map embeddings back to the original batch even if you do additional processing later

When To Batch

  • indexing many documents or chunks
  • reducing per-request overhead
  • building offline retrieval corpora

Common mistakes

  • batching inputs from different workflows when you need separate metadata
  • assuming the response order can be inferred without using index
  • sending a giant batch without thinking about request size, retries, and indexing checkpoints

Reference