Skip to content
dhanu docs
Browse pages

API reference

Create embeddings

POST /api/pub/v1/embeddings, turn up to 100 texts into vectors.

POSThttps://api.dhanu.ai/api/pub/v1/embeddings

Embeds up to 100 texts with the workspace embedding model and returns one vector per input, in order. Use it to build your own search or clustering over content that lives outside Dhanu. The call is billed by input tokens; a test key returns deterministic 8-dimensional fixtures at no cost.

Request

FieldTypeRequiredNotes
inputarrayYes
projectIdstringNoWhich of the key's projects the call runs against. Required when the key can access more than one project.
curl -X POST https://api.dhanu.ai/api/pub/v1/embeddings \
  -H "Authorization: Bearer $DHANU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "input": ["momo recipe", "thukpa recipe"] }'
const { embeddings, model } = await dhanu.embeddings.create({
  input: ["momo recipe", "thukpa recipe"],
});
result = dhanu.embeddings.create(["momo recipe", "thukpa recipe"])
vectors = result.embeddings

Response

201 Created

{ "embeddings": [[0.0123, -0.0456, …], [0.0087, -0.0391, …]], "model": "…", "usage": { "inputTokens": 9 }, "cost": { "amount": 1, "currency": "NPR" } }

Errors

CodeStatusMeaning
invalid_api_key401The bearer key is missing or unknown.
api_key_revoked401The key was revoked.
api_key_expired401The key passed its expiry date.
api_key_ip_not_allowed403The caller's IP is outside the key's allowlist.
developer_access_revoked403The key's creator lost developer access in the workspace.
api_key_project_scope403The key covers no active projects, or projectId is outside its scope.
invalid_request_body422The body did not match the schema; error.issues names each field.
project_id_required422A multi-project key called without projectId.
insufficient_credits402The workspace credit balance is zero or below.
key_spend_limit_reached402The key reached its monthly spend cap.
invalid_generation_prompt422The prompt was empty or longer than 2000 characters.