Gemini generateContent (metered tier)
POST /v1/metered/geminiGoogle's native generateContent wire on the metered tier. Send Gemini's own request shape (contents, systemInstruction, generationConfig, function declarations) and get Gemini's own response shape (candidates, usageMetadata) back. Point a Google GenAI SDK at this gateway and pay per request with USDC, no account. Also answers the Google-shaped path /v1beta/models/<model>:generateContent.
Input
| Field | Type | Description |
|---|---|---|
contents * | array | Gemini turns: [{role, parts:[{text}|{inlineData}]}] |
systemInstruction | object | Optional system turn: {parts:[{text}]} |
generationConfig | object | maxOutputTokens, temperature, topP, stopSequences, responseMimeType, responseSchema |
tools | array | [{functionDeclarations:[{name, description, parameters}]}] |
model | string | Optional; the Google-shaped path carries it (/v1beta/models/<model>:generateContent) |
Example output
{
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"text": "x402 is an HTTP-native way for agents to pay per request with USDC."
}
]
},
"finishReason": "STOP",
"index": 0
}
],
"usageMetadata": {
"promptTokenCount": 14,
"candidatesTokenCount": 18,
"totalTokenCount": 32
},
"modelVersion": "google/gemini-2.5-flash"
}
Try it - see the 402 challenge (free)
curl -i -X POST https://agent402.tools/v1/metered/gemini \
-H "Content-Type: application/json" \
-d '{"contents":[{"role":"user","parts":[{"text":"Summarize x402 in one sentence."}]}],"generationConfig":{"maxOutputTokens":256}}'
The response is HTTP 402 Payment Required with exact payment requirements. Any x402 v2 client pays automatically and retries:
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
import { metaTitle, metaDescription } from "./seo-meta.js";
const client = new x402Client();
client.setSpendControls?.(false); // @x402/core 2.23+ refuses anything over $1 or off the pegged-asset list by default; keep your own ceiling in code instead
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/v1/metered/gemini", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"contents": [
{
"role": "user",
"parts": [
{
"text": "Summarize x402 in one sentence."
}
]
}
],
"generationConfig": {
"maxOutputTokens": 256
}
}),
});
Related tools
Chat completions - metered (pay what the call costs)
POST /v1/metered/chat/completionsOpenAI-compatible chat completions billed per request from what the call costs: the 402 quotes exact-BPE input plus your…
try in playground →Chat completions - nano tier
POST /v1/nano/chat/completionsOpenAI-compatible chat completions, nano tier: gpt-5.6-luna, gpt-5-nano, gemini flash-lite, small llama/ministral/qwen, …
try in playground →Chat completions - auto tier (eval-ranked routing)
POST /v1/auto/chat/completionsOpenAI-compatible chat completions with server-side model choice: omit "model" (or send "auto") and the gateway routes t…
try in playground →