--- title: "New: the Embeddings API. Any web page to vectors in one call" category: "release" url: https://keirolabs.cloud/blog/embeddings-api --- Send a URL, get back vectors. The new **`/v2/embeddings`** endpoint extracts the page, splits it into chunks and embeds every chunk in one call, so a RAG pipeline over web pages no longer needs a scraper, a chunker and an embedding model wired together. It costs **3 credits per URL**, about **$2.67 per 1,000 pages** on Startup. Embedding a question costs 0.1 credits. ## What the endpoint does `POST /api/v2/embeddings` takes two kinds of input, alone or together: - **`urls`**: up to 10 pages, HTML or PDF. Web pages go through the same extractor as `/v2/extract` (up to 30,000 characters each); PDFs are read directly (up to 300,000 characters). The text is split into chunks of about 2,000 characters at paragraph, line or sentence ends, never mid-word, and every chunk is embedded as a document. - **`input`**: up to 128 strings, such as your users' questions. They're embedded as queries with the same model, so a question vector can be compared directly with the page vectors. Every page chunk comes back with its `url`, `title`, chunk number and `text`, so you can store the vector and the text it came from in one write. ```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?" }' ``` The response uses the OpenAI embeddings format (`object: "list"`, `data[].embedding`), so it drops into any vector database or framework that already reads OpenAI embeddings. ## The model Vectors come from **voyage-4-lite** by Voyage AI (now part of MongoDB). You choose the size: 256, 512, 1024 (the default) or 2048 dimensions. Smaller vectors cost less to store and search; use the same size for your queries and your pages. Questions are embedded as `query` and page chunks as `document`. That's how Voyage recommends using its models for search. ## Pricing | What | Credits | Essential | Pro | Startup | |---|---|---|---|---| | One URL (extract, chunk, embed) | 3 | $8.00 / 1,000 | $4.44 / 1,000 | $2.67 / 1,000 | | Text in `input` | 0.1 per 10,000 characters | | | | | A URL that fails | 0 | | | | The price is the same on every plan. If a URL can't be extracted, the response lists it under `errors` and you aren't charged for it. The 750 free signup credits cover 250 pages. ## Search a page in a few lines `data[0]` is the question, and the rest are the page's chunks. Rank chunks by cosine similarity and take the top ones: ```python import math, os, requests r = requests.post( "https://api.keirolabs.cloud/api/v2/embeddings", headers={"Authorization": f"Bearer {os.environ['KEIRO_API_KEY']}"}, json={"urls": ["https://keirolabs.cloud/pricing"], "input": "how much does lite cost?"}, ).json() cos = lambda a, b: sum(x * y for x, y in zip(a, b)) / (math.hypot(*a) * math.hypot(*b)) q, chunks = r["data"][0]["embedding"], r["data"][1:] for c in sorted(chunks, key=lambda c: -cos(q, c["embedding"]))[:3]: print(round(cos(q, c["embedding"]), 3), c["text"][:120]) ``` In production you'd write `chunks` into your vector database once, then embed each new question with `input` and query the database. ## Try it in the playground The [playground](https://platform.keirolabs.cloud/playground/v3?endpoint=embeddings) runs the endpoint on any page: paste a URL, type a question, and it shows every chunk ranked by how close it is to the question. Full reference: [docs.keirolabs.cloud/content/embeddings](https://docs.keirolabs.cloud/content/embeddings).