API reference
Create embeddings
POST /api/pub/v1/embeddings, turn up to 100 texts into vectors.
POST
https://api.dhanu.ai/api/pub/v1/embeddingsEmbeds 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
| Field | Type | Required | Notes |
|---|---|---|---|
input | array | Yes | |
projectId | string | No | Which 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
| Code | Status | Meaning |
|---|---|---|
invalid_api_key | 401 | The bearer key is missing or unknown. |
api_key_revoked | 401 | The key was revoked. |
api_key_expired | 401 | The key passed its expiry date. |
api_key_ip_not_allowed | 403 | The caller's IP is outside the key's allowlist. |
developer_access_revoked | 403 | The key's creator lost developer access in the workspace. |
api_key_project_scope | 403 | The key covers no active projects, or projectId is outside its scope. |
invalid_request_body | 422 | The body did not match the schema; error.issues names each field. |
project_id_required | 422 | A multi-project key called without projectId. |
insufficient_credits | 402 | The workspace credit balance is zero or below. |
key_spend_limit_reached | 402 | The key reached its monthly spend cap. |
invalid_generation_prompt | 422 | The prompt was empty or longer than 2000 characters. |