POST /v1/embeddingsOpenAI-compatible text embeddings over x402 — point any OpenAI SDK at base_url https://agent402.tools/v1 and pay $0.002 per call in USDC, no API key, no signup. Batch up to 64 inputs / 16k chars per request; text-embedding-3-small by default (3-large and ada-002 supported; dimensions and encoding_format pass through). Embeddings are deterministic, so a byte-identical repeat within 10 minutes is served FREE from cache automatically (X-Cache: hit; opt out with cache:false).
| Field | Type | Description |
|---|---|---|
input * | string | Text to embed — a string or an array of up to 64 strings (16k chars total) |
model | string | Optional — text-embedding-3-small (default), text-embedding-3-large, or text-embedding-ada-002 |
dimensions | number | Optional output dimensions (3-small/3-large only) |
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [
0.0023,
-0.0091,
0.0152
]
}
],
"model": "text-embedding-3-small",
"usage": {
"prompt_tokens": 12,
"total_tokens": 12
}
}
curl -i -X POST https://agent402.tools/v1/embeddings \
-H "Content-Type: application/json" \
-d '{"input":"Agent402 is an open-source x402 tool server."}'
The response is HTTP 402 Payment Required with exact payment requirements. Any x402 v2 client pays automatically and retries:
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/v1/embeddings", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"input": "Agent402 is an open-source x402 tool server."
}),
});
POST /v1/nano/chat/completionsOpenAI-compatible chat completions, nano tier: gpt-4.1-nano, gpt-5-nano, gemini flash-lite, small llama/ministral/qwen, …
POST /v1/auto/chat/completionsOpenAI-compatible chat completions with server-side model choice: omit "model" (or send "auto") and the gateway routes t…
POST /v1/chat/completionsOpenAI-compatible chat completions over x402 — point any OpenAI SDK at base_url https://agent402.tools/v1 and pay per ca…