Skip to content

API reference

Embeddings

Turn text into vectors for similarity workflows. Select an embedding-capable model and keep vector dimensions consistent in your own index.

How it fits together

  1. 01Create embedding vectors for one or more inputs

Select an action to see its complete inputs, request, response, and status codes.

Create embedding vectors for one or more inputs

POST/v1/embeddings
Production base URLhttps://api.mahvashai.ir
AuthenticationProject API key or user JWT
ResponseDirect OpenAI-style response
Content typeapplication/json

Parameters

The table shows the accepted inputs for this endpoint. Examples use placeholders and illustrate a safe integration pattern.

NameLocationTypeRequiredSupportDetails
Idempotency-KeyHeaderstringOptionalSupportedReplay key for an admitted run; a repeat returns the first result.
X-Request-IDHeaderstringOptionalMahvash extensionClient-supplied correlation ID. Echoed on every response; replaced when absent or malformed.
X-Mahvash-ProjectHeaderstringOptionalMahvash extensionProject slug or ID within the caller's organization. Narrows the request principal; it can never widen it.
dimensionsBodyintegerOptionalConditionalOutput vector width. Accepted only on a model whose catalog entry publishes that width; every other value is refused before any provider call.
encoding_formatBodystringOptionalSupportedfloat or base64.
inputBodystring | array<value>RequiredSupportedA string, an array of strings, a token array, or an array of token arrays. Batch size and per-item and total token counts are bounded by service configuration.
modelBodystringRequiredSupportedPublic logical embedding model ID.
userBodystringOptionalSupportedProvider abuse-monitoring user identifier.

A compatible model and provider route are required for conditional fields.

Request

curl -X POST 'https://api.mahvashai.ir/v1/embeddings' \
  -H "Authorization: Bearer $MAHVASH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: <unique-request-id>" \
  -d '{
  "model": "<embedding-model-from-GET-/v1/models>",
  "input": "A short document to embed."
}'

Response

{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [
        0.012,
        -0.021,
        0.037
      ]
    }
  ],
  "model": "<embedding-model-id>",
  "usage": {
    "prompt_tokens": 8,
    "total_tokens": 8
  }
}

Illustrative response shape; actual fields depend on the operation and model.

Status codes

HTTPDetails
200Create embedding vectors for one or more inputs.
400The request is not valid.
401Authentication credentials are missing or invalid.
402The account cannot authorize the request cost.
403The principal is not allowed to perform this request.
404No such resource is visible to this principal.
409The requested transition conflicts with durable resource state.
429A quota or rate limit was exceeded.
500An internal error occurred.
502The selected provider returned an invalid or failed response.
503A dependency is temporarily unavailable.