Content

Embeddings

Turn web pages and text into vectors in one call. OpenAI-compatible.

Open in…
Ask on Discord
What your agent reads
`POST https://api.keirolabs.cloud/api/v2/embeddings`

Cost: 3 credits per URL · Latency: 2s - 15s

Send URLs and get back vectors. Each page (HTML or PDF) is extracted to clean text, split into chunks and embedded, so you skip the scraper, the chunker and the embedding model. Send text (such as your users' questions) and it's embedded with the same model, so query vectors and page vectors can be compared directly.

The response uses the OpenAI embeddings format, so it drops into any vector database or framework that reads OpenAI embeddings. Every page chunk also comes back with its `url`, `title`, chunk number and `text`, ready to store next to the vector.

**Model.** `voyage-4-lite` (Voyage AI by MongoDB). 1024 dimensions by default, or 256, 512 or 2048.

**When to use it.** Building RAG or semantic search over web pages: index docs sites, competitor pages or any list of URLs, then embed each user question with `input` and search.

**When not to.** If you only need the page text, use [Extract](/content/extract). If you need to find the pages first, use [Search + Content](/content/search-content).

## Request

**cURL**

```bash
curl -X POST https://api.keirolabs.cloud/api/v2/embeddings \
  -H "Authorization: Bearer $KEIRO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "urls": ["https://en.wikipedia.org/wiki/Retrieval-augmented_generation"],
    "input": "how does RAG reduce hallucinations?"
  }'
```

**Python**

```python
import os, requests

res = requests.post(
    "https://api.keirolabs.cloud/api/v2/embeddings",
    headers={"Authorization": f"Bearer {os.environ['KEIRO_API_KEY']}"},
    json={
        "urls": ["https://en.wikipedia.org/wiki/Retrieval-augmented_generation"],
        "input": "how does RAG reduce hallucinations?",
    },
)
data = res.json()["data"]

# data[0] is the question (from `input`), the rest are page chunks.
import math
cos = lambda a, b: sum(x * y for x, y in zip(a, b)) / (math.hypot(*a) * math.hypot(*b))
q = data[0]["embedding"]
best = max(data[1:], key=lambda c: cos(q, c["embedding"]))
print(best["url"], best["text"][:300])
```

**Node.js**

```js
const res = await fetch("https://api.keirolabs.cloud/api/v2/embeddings", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KEIRO_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    urls: ["https://en.wikipedia.org/wiki/Retrieval-augmented_generation"],
    input: "how does RAG reduce hallucinations?",
  }),
});
const { data } = await res.json();
console.log(data.length, "vectors");
```

## Parameters

Send `urls`, `input`, or both.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `urls` | string | string[] | no | A URL or an array of up to 10. Web pages are extracted up to 30,000 characters and PDFs up to 300,000, then chunked and embedded as documents. Must be public http(s) URLs; internal targets are blocked. |
| `input` | string | string[] | no | Text to embed: a string or an array of up to 128 strings, 100,000 characters in total. Embedded as a query by default. |
| `input_type` | enum | no | How to embed \`input\`: "query" (default, for search questions) or "document" (for text you will search over). Page chunks from \`urls\` are always "document". |
| `dimensions` | integer | no | Vector size: 256, 512, 1024 (default) or 2048. Use the same value for queries and pages. |
| `chunk_size` | integer | no | Maximum characters per page chunk, 200 to 8,000. Default: 2,000. Chunks break at paragraphs, then lines, then sentences, never mid-word. Repeated lines (menus, footers) are kept once. |

## Response

```json title="200 OK"
{
  "object": "list",
  "model": "voyage-4-lite",
  "dimensions": 1024,
  "data": [
    { "object": "embedding", "index": 0, "embedding": [0.0107, 0.0146, "..."] },
    {
      "object": "embedding",
      "index": 1,
      "embedding": [0.0143, -0.0109, "..."],
      "url": "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
      "title": "Retrieval-augmented generation",
      "chunk": 0,
      "text": "Retrieval-augmented generation (RAG) is a technique that enables large language models..."
    }
  ],
  "usage": { "prompt_tokens": 6211, "total_tokens": 6211 },
  "creditsCharged": 3.1,
  "creditsRemaining": 11246.9
}
```

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | array | no | Vectors in order: first one per \`input\` string, then one per page chunk. |
| `data[].embedding` | number[] | no | The vector. |
| `data[].url` | string | no | Page the chunk came from (page chunks only). |
| `data[].title` | string | no | Page title (page chunks only). |
| `data[].chunk` | integer | no | Position of the chunk in the page, from 0 (page chunks only). |
| `data[].text` | string | no | The chunk's text, to store next to the vector (page chunks only). |
| `errors` | array | no | URLs that could not be extracted, with the reason. Present only when some failed; those URLs are not charged. |
| `usage.total_tokens` | integer | no | Tokens embedded. |
| `creditsCharged` | number | no | 3 per URL that succeeded, plus 0.1 per 10,000 characters of \`input\`. |

## Cost

| What | Credits |
| --- | --- |
| Each URL (extract, chunk and embed) | 3 |
| Text in `input` | 0.1 per 10,000 characters |
| A URL that fails | 0 |

Same price on every plan. Embedding a search question costs 0.1 credits, so you can embed every user query.

## Use with the OpenAI SDK

Text-only calls are OpenAI-compatible, so you can point the OpenAI client at Keiro:

```python
import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["KEIRO_API_KEY"], base_url="https://api.keirolabs.cloud/api/v2")
vec = client.embeddings.create(model="voyage-4-lite", input="how does RAG work?").data[0].embedding
```

## Errors

| Status | Code | Cause | Fix |
| --- | --- | --- | --- |
| `400` | `VALIDATION_ERROR` | No `urls` or `input`, too many items, or a bad `dimensions` / `chunk_size` | Check the limits above. Nothing was charged. |
| `400` | | A URL's domain doesn't resolve or is blocked | Use public http(s) URLs. Nothing was charged. |
| `401` | `UNAUTHORIZED` | Missing or invalid API key | Check your Authorization: Bearer header. |
| `402` | `INSUFFICIENT_CREDITS` | Not enough credits | Buy more credits or upgrade at /dashboard/billing. Nothing was charged. |
| `429` | `RATE_LIMIT_EXCEEDED` | Too many requests | Check X-RateLimit-Remaining header. |
| `502` | | Every URL failed to extract, or embedding failed | Credits refunded automatically. Retry. |

## Rate limits

| Tier | Limit |
| --- | --- |
| Free | 10/min |
| Starter | 30/min |
| Pro | 60/min |
| Startup | 120/min |
| Enterprise | 200/min |

Over the limit you get a `429`. See [Rate limits](/rate-limits) for headers and backoff.
Every page: append .md to the URL. Whole site: /llms.txt · /llms-full.txt
POSThttps://api.keirolabs.cloud/api/v2/embeddings
3 credits per URL2s - 15sTry it in the playground

Send URLs and get back vectors. Each page (HTML or PDF) is extracted to clean text, split into chunks and embedded, so you skip the scraper, the chunker and the embedding model. Send text (such as your users' questions) and it's embedded with the same model, so query vectors and page vectors can be compared directly.

The response uses the OpenAI embeddings format, so it drops into any vector database or framework that reads OpenAI embeddings. Every page chunk also comes back with its url, title, chunk number and text, ready to store next to the vector.

Model. voyage-4-lite (Voyage AI by MongoDB). 1024 dimensions by default, or 256, 512 or 2048.

When to use it. Building RAG or semantic search over web pages: index docs sites, competitor pages or any list of URLs, then embed each user question with input and search.

When not to. If you only need the page text, use Extract. If you need to find the pages first, use Search + Content.

Request

curl -X POST https://api.keirolabs.cloud/api/v2/embeddings \
  -H "Authorization: Bearer $KEIRO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "urls": ["https://en.wikipedia.org/wiki/Retrieval-augmented_generation"],
    "input": "how does RAG reduce hallucinations?"
  }'

Parameters

Send urls, input, or both.

Prop

Type

Response

200 OK
{
  "object": "list",
  "model": "voyage-4-lite",
  "dimensions": 1024,
  "data": [
    { "object": "embedding", "index": 0, "embedding": [0.0107, 0.0146, "..."] },
    {
      "object": "embedding",
      "index": 1,
      "embedding": [0.0143, -0.0109, "..."],
      "url": "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
      "title": "Retrieval-augmented generation",
      "chunk": 0,
      "text": "Retrieval-augmented generation (RAG) is a technique that enables large language models..."
    }
  ],
  "usage": { "prompt_tokens": 6211, "total_tokens": 6211 },
  "creditsCharged": 3.1,
  "creditsRemaining": 11246.9
}

Prop

Type

Cost

WhatCredits
Each URL (extract, chunk and embed)3
Text in input0.1 per 10,000 characters
A URL that fails0

Same price on every plan. Embedding a search question costs 0.1 credits, so you can embed every user query.

Use with the OpenAI SDK

Text-only calls are OpenAI-compatible, so you can point the OpenAI client at Keiro:

import os
from openai import OpenAI

client = OpenAI(api_key=os.environ["KEIRO_API_KEY"], base_url="https://api.keirolabs.cloud/api/v2")
vec = client.embeddings.create(model="voyage-4-lite", input="how does RAG work?").data[0].embedding

Errors

StatusCodeCauseFix
400VALIDATION_ERRORNo urls or input, too many items, or a bad dimensions / chunk_sizeCheck the limits above. Nothing was charged.
400A URL's domain doesn't resolve or is blockedUse public http(s) URLs. Nothing was charged.
401UNAUTHORIZEDMissing or invalid API keyCheck your Authorization: Bearer header.
402INSUFFICIENT_CREDITSNot enough creditsBuy more credits or upgrade at /dashboard/billing. Nothing was charged.
429RATE_LIMIT_EXCEEDEDToo many requestsCheck X-RateLimit-Remaining header.
502Every URL failed to extract, or embedding failedCredits refunded automatically. Retry.

Rate limits

TierLimit
Free10/min
Starter30/min
Pro60/min
Startup120/min
Enterprise200/min

Over the limit you get a 429. See Rate limits for headers and backoff.

Let your agent build it

Paste one prompt into Claude Code, Cursor, Codex or Windsurf. It installs Keiro MCP, reads these docs and writes the integration against the real API.

Ask on Discord

On this page