Gemini generateContent (base tier)

quoted per request from $0.020 · USDC via x402 · POST /v1/gemini

Google's native generateContent wire on the base tier. Send POST /v1/gemini with the required field contents and pay quoted per request from $0.020 over x402 or MPP (there is no free tier). It returns a JSON object with candidates, usageMetadata and modelVersion.

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.

Category: LLM gateway · Tags: llm gemini google generatecontent chat

TRY IN PLAYGROUND →

Parameters

NameTypeRequiredDescription
contentsarrayyesGemini turns: [{role, parts:[{text}|{inlineData}]}]
systemInstructionobjectnoOptional system turn: {parts:[{text}]}
generationConfigobjectnomaxOutputTokens, temperature, topP, stopSequences, responseMimeType, responseSchema
toolsarrayno[{functionDeclarations:[{name, description, parameters}]}]
modelstringnoOptional; the Google-shaped path carries it (/v1beta/models/<model>:generateContent)

Example request

curl -i -X POST https://agent402.tools/v1/gemini \
  -H "Content-Type: application/json" \
  -d '{"contents":[{"role":"user","parts":[{"text":"Summarize x402 in one sentence."}]}],"generationConfig":{"maxOutputTokens":256}}'

Without payment this returns HTTP 402 Payment Required with the exact price for v1-chat-gemini; any x402 v2 or MPP client pays it and retries.

Example response

{
  "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-3.5-flash-lite"
}
FieldTypeAlways presentIn the example
candidatesarray of objectsyes1 item in the example
usageMetadataobjectyes3 fields: promptTokenCount, candidatesTokenCount, totalTokenCount
modelVersionstringyesgoogle/gemini-3.5-flash-lite

From an MCP client

catalog.call {
  "slug": "v1-chat-gemini",
  "params": {
    "contents": [
      {
        "role": "user",
        "parts": [
          {
            "text": "Summarize x402 in one sentence."
          }
        ]
      }
    ],
    "generationConfig": {
      "maxOutputTokens": 256
    }
  }
}

The hosted connector at https://agent402.tools/mcp needs a payment for v1-chat-gemini; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.

Errors and behavior

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";

const client = new x402Client();
client.setSpendControls?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/v1/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

Gemini generateContent (auto tier)

$0.010 · POST /v1/auto/gemini

Google's native generateContent wire on the auto tier. Send Gemini's own request shape (contents, systemInstruction, gen…

Gemini generateContent (metered tier)

$0.001 · POST /v1/metered/gemini

Google's native generateContent wire on the metered tier. Send Gemini's own request shape (contents, systemInstruction, …

Gemini generateContent (nano tier)

$0.003 · POST /v1/nano/gemini

Google's native generateContent wire on the nano tier. Send Gemini's own request shape (contents, systemInstruction, gen…

Gemini generateContent (premium tier)

$0.500 · POST /v1/premium/gemini

Google's native generateContent wire on the premium tier. Send Gemini's own request shape (contents, systemInstruction, …

Gemini generateContent (pro tier)

$0.100 · POST /v1/pro/gemini

Google's native generateContent wire on the pro tier. Send Gemini's own request shape (contents, systemInstruction, gene…

Text-to-speech (OpenAI-compatible)

$0.060 · POST /v1/audio/speech

OpenAI-compatible text-to-speech over x402 - point any OpenAI SDK's audio.speech.create() at base_url https://agent402.t…