# Generate text embeddings for semantic search with ZeroGPU's API

ZeroGPU's embeddings API turns one string or a batch of strings into 384-dimension vectors for semantic search, RAG, deduplication and clustering, in OpenAI's embeddings envelope. Billing counts input tokens only: $0.004 per million tokens on `all-minilm-l6-v2` and $0.004 per million tokens on `bge-small-en-v1.5`, drawn from prepaid credit. Send `POST https://agents.zerogpu.ai/zcj/k29q3b2vjays/zeroclick/v1/embeddings` with `model` and `input`, authorized with a credential that holds credit.

## At a glance

- **Endpoint:** `POST https://agents.zerogpu.ai/zcj/k29q3b2vjays/zeroclick/v1/embeddings`
- **Body:** `model` (`all-minilm-l6-v2` or `bge-small-en-v1.5`, both required) and `input` (one string or an array of strings, both required)
- **Price:** `all-minilm-l6-v2` $0.004 per million tokens, `bge-small-en-v1.5` $0.004 per million tokens. Only input tokens are billed.
- **Payment:** calls draw on prepaid Credits. Buying or topping up Credits is the only step with a 402 price quote, from $0.01 on a wallet rail or $0.50 by card.
- **Auth on calls:** `Authorization: Bearer <token>` for an agent credential that holds Credits, or `Authorization: Receipt <receiptId>` for a small credit bought without registering
- **Response:** `data[i].embedding`, 384 numbers per input, matched to the input by `data[i].index`, plus `model` and `usage`
- **Full purchase flow:** [the buyer skill](https://agents.zerogpu.ai/zcj/k29q3b2vjays/SKILL.md)

## Embed strings and read the vectors

1. Get credit. Buy Credits with a registered agent credential at `POST https://agents.zerogpu.ai/zcj/k29q3b2vjays/plans/{planId}/purchase`, paying the 402 price quote over x402 or MPP (the wallet rails, in USDC) or by card, as [the buyer skill](https://agents.zerogpu.ai/zcj/k29q3b2vjays/SKILL.md) sets out. To test without registering, buy a small anonymous credit and send its receipt instead. Embedding calls then draw on that balance and get no 402 of their own.

2. Embed a batch. Send every string in one request as an array:

   ```bash
   curl -s https://agents.zerogpu.ai/zcj/k29q3b2vjays/zeroclick/v1/embeddings \
     -H "Authorization: Bearer $ACCESS_TOKEN" \
     -H "content-type: application/json" \
     -d '{"model": "all-minilm-l6-v2", "input": ["How do I reset my password?", "I forgot my login details."]}'
   ```

   The response has this shape:

   ```json
   {
     "object": "list",
     "data": [
       {"object": "embedding", "index": 0, "embedding": ["<384 numbers>"]},
       {"object": "embedding", "index": 1, "embedding": ["<384 numbers>"]}
     ],
     "model": "all-MiniLM-L6-v2",
     "usage": {"prompt_tokens": "<integer>", "total_tokens": "<integer>"}
   }
   ```

   For the two-string batch, the response holds two `data` entries, one per string, each with its `index` and a 384-number `embedding`. The response's `model` reads `all-MiniLM-L6-v2`, capitalized, so match results on the id you sent.

3. Embed a single string. A query at search time is one string:

   ```bash
   curl -s https://agents.zerogpu.ai/zcj/k29q3b2vjays/zeroclick/v1/embeddings \
     -H "Authorization: Bearer $ACCESS_TOKEN" \
     -H "content-type: application/json" \
     -d '{"model": "bge-small-en-v1.5", "input": "What is the refund window for annual plans?"}'
   ```

   The response holds one `data` entry at `index` 0 with a 384-number `embedding`. Write the model id as `bge-small-en-v1.5`, with the dot. The catalog slug `bge-small-en-v1-5` is never a request value.

4. Map each vector back to its input. Use `data[i].index`, the position of the input string the vector came from, and store each vector next to its text.

5. Read the balance from the response headers. A response that draws credit carries a `zc-billing` header in this shape:

   ```
   zc-billing: {"fundingSource": "credit", "chargedUsd": "<amount>", "remainingCreditUsd": "<amount>"}
   ```

   `chargedUsd` is what this call drew from your credit, and `remainingCreditUsd` is the balance after it.

## Choose a model

| Job | `model` |
| --- | --- |
| General sentence similarity, deduplication, clustering, recommendation over short chunks | `all-minilm-l6-v2` |
| Matching English passages to a query, for RAG and corpus search | `bge-small-en-v1.5` |
| Chunks up to 256 tokens | `all-minilm-l6-v2` |
| English passages up to 512 tokens | `bge-small-en-v1.5` |

Both models return 384-dimension vectors.

## Billing and boundaries

- Billing counts input tokens only. Embeddings produce no output tokens, so `usage.prompt_tokens` is what you are billed for.
- The request takes two fields, `model` and `input`. Vector size is fixed at 384 for both models.
- The service truncates any input that runs past the model's maximum token length, so embed chunks rather than whole documents.
- The two embedding models answer only on this endpoint.
- Nothing is charged until you pay the Credits purchase's 402, so reading the catalog and getting the quote are safe places to stop. After that, each embeddings call draws its input-token cost from the balance.
- A receipt spends only its own small balance and cannot be topped up. Losing the receipt loses what is left on it.

## Errors

| Response | Meaning | Action |
| --- | --- | --- |
| `400` | Malformed JSON, or `model` or `input` missing or invalid | Fix the body. Use one of the two model ids exactly as written. |
| `401 bearer_required` | The call carried no credential | Register at [auth.md](https://agents.zerogpu.ai/zcj/k29q3b2vjays/auth.md), buy Credits, then retry with `Authorization: Bearer <token>` |
| `401 invalid_receipt` | The receipt is malformed, pending, revoked or from another seller | Send only the `receiptId` from a successful credit purchase |
| `402 receipt_credit_exhausted` or `receipt_credit_insufficient` | The receipt's balance cannot cover the call | Buy a new receipt, or buy a larger balance of Credits with an agent credential |
| `403 plan_required` | Your credential holds no plan that covers the call | Buy Credits from the `purchase.url` in the body, then retry |
| `usage_exhausted` | Your Credits balance ran out | Top up with `POST https://agents.zerogpu.ai/zcj/k29q3b2vjays/extend` and `{"amountUsd": "<amount>"}` |
| `429` | Rate limit reached | Wait at least `retry-after` seconds, then retry |

## Frequently asked questions

### Is ZeroGPU's embeddings endpoint OpenAI-compatible?

Yes. It takes OpenAI's embeddings request body, `model` plus `input` as a string or an array of strings. It returns OpenAI's embeddings list, with `object`, `data`, `model` and `usage`. Through the storefront, send the request to `https://agents.zerogpu.ai/zcj/k29q3b2vjays/zeroclick/v1/embeddings` with the storefront's credential. You do not need a ZeroGPU API key.

### How many dimensions do the embeddings have?

384, for both `all-minilm-l6-v2` and `bge-small-en-v1.5`. Each `data[i].embedding` is an array of 384 numbers.

### Can I embed many strings in one request?

Yes. Send `input` as an array and the response returns one vector per element. Each vector carries `index`, the position of its input, so you can match vectors to strings without relying on order.

### How are embeddings billed?

On input tokens only, at $0.004 per million tokens for `all-minilm-l6-v2` and $0.004 per million tokens for `bge-small-en-v1.5`. Each call draws the cost from prepaid credit. The `zc-billing` header on the response reports `chargedUsd` and `remainingCreditUsd`.

### Do I need an account to call the embeddings API?

You need either an agent credential that holds Credits or a receipt from a small credit bought without registering. Registering a credential needs no email. The 402 price quote appears only when you buy Credits, which you settle once over x402, MPP or card.

## Keep reading

- [Buyer skill](https://agents.zerogpu.ai/zcj/k29q3b2vjays/SKILL.md): the full purchase flow
- [How to pay](https://agents.zerogpu.ai/zcj/k29q3b2vjays/payment.md): the Credits purchase, rails and top-ups
- [Identity](https://agents.zerogpu.ai/zcj/k29q3b2vjays/auth.md): register and present an agent credential
- [Error reference](https://agents.zerogpu.ai/zcj/k29q3b2vjays/errors.md): every error code and how to react

---

Updated 2026-10-14. All ZeroGPU guides: https://agents.zerogpu.ai/guides.md. Storefront: https://agents.zerogpu.ai/zcj/k29q3b2vjays/llms.txt.
