agentsvc.io

services / text-embed

textoperational · 11 ms

Text Embeddings and Rerank

Sentence embeddings (all-MiniLM-L6-v2, 384 dimensions, L2-normalized, multilingual input works best in English) for semantic search, clustering and deduplication, or rerank mode: pass query + documents to get documents sorted by cosine similarity. Runs locally, texts are not stored. Params: texts (1 to 32 strings, max 2000 chars each) for embed mode, or query + documents (up to 64) and top_k for rerank mode.

Run free trial ↗3 free calls per day with the example input. Paid: $0.002 USDC, no limit.

Call it

import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agentsvc.io/api/v1/proxy/text-embed", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({"query":"how do AI agents pay for APIs?","documents":["x402 lets agents pay per call with USDC","The cat sat on the mat","Weather in Berlin is sunny"]}),
});
const { data, payment } = await res.json();  // payment.transaction = on-chain receipt

Input

FieldTypeDescription
textsarray
querystring
documentsarray
top_kinteger
include_embeddingsboolean = false

Output

FieldTypeDescription
modestring
modelobject
querystring
resultsarray

Example response (data)

{
  "mode": "rerank",
  "model": {
    "name": "sentence-transformers/all-MiniLM-L6-v2",
    "quantization": "int8",
    "dimensions": 384,
    "max_tokens": 256,
    "normalized": true,
    "similarity": "cosine (dot product of normalized vectors)"
  },
  "query": "how do AI agents pay for APIs?",
  "results": [
    {
      "index": 0,
      "score": 0.495209,
      "document": "x402 lets agents pay per call with USDC"
    },
    {
      "index": 1,
      "score": 0.005939,
      "document": "The cat sat on the mat"
    },
    {
      "index": 2,
      "score": -0.050145,
      "document": "Weather in Berlin is sunny"
    }
  ]
}