Technology Aug 23, 2026 · 3 min read

Cheap OpenAI-compatible inference for AI agents via x402 ($0.10/1M tokens on Solana + Base)

If you're building an autonomous AI agent, you've probably hit the same wall I did: your bot needs LLM inference, but every provider wants an API key, a credit card, a signup flow. That flow assumes a human operator, not a self-directed agent. x402 solves that. It's the HTTP status-code-based payme...

DE
DEV Community
by GitVova999
Cheap OpenAI-compatible inference for AI agents via x402 ($0.10/1M tokens on Solana + Base)

If you're building an autonomous AI agent, you've probably hit the same wall I did: your bot needs LLM inference, but every provider wants an API key, a credit card, a signup flow. That flow assumes a human operator, not a self-directed agent.

x402 solves that. It's the HTTP status-code-based payment protocol Coinbase revived last year — the server says "402 Payment Required", the client signs a USDC micropayment, retries, and gets the resource. No accounts, no keys, no rate-limit tiers.

I've been running a plain OpenAI-compatible inference relay on x402 for the past week. Sharing it here in case others building agents want cheap LLM access without the signup dance.

OpenRelay — the endpoint

https://openrelay.hggfffdfy687.workers.dev/v1/chat/completions

OpenAI SDK compatible. Just change your base_url.

What you get

  • Pricing: $0.10 per 1M tokens (input + max_tokens). Charged per request in USDC.
  • Networks: Solana mainnet or Base mainnet — single 402 response advertises both, your client picks whichever chain you hold USDC on.
  • Facilitator: PayAI (gasless — you don't pay chain gas, the facilitator sponsors it).
  • Models:
    • deepseek-ai/DeepSeek-V4-Flash-0731 — 400k context
    • moonshotai/Kimi-K2.6 — 240k context
    • MiniMaxAI/MiniMax-M2.7 — 180k context
  • Zero signup, zero API keys, zero rate-limit tiers. The only thing gating you is having USDC in your wallet.

How to actually pay from a Python agent

import asyncio
from eth_account import Account

from x402 import SchemeRegistration, x402ClientConfig
from x402.http.clients.httpx import wrapHttpxWithPaymentFromConfig
from x402.mechanisms.evm.exact.client import ExactEvmScheme
from x402.mechanisms.evm.signers import EthAccountSigner

# Your Base wallet with USDC
acct = Account.from_key("0x<your-private-key>")
signer = EthAccountSigner(acct)

config = x402ClientConfig(
    schemes=[SchemeRegistration(
        network="eip155:8453",  # Base mainnet
        client=ExactEvmScheme(signer=signer),
    )],
)

async def main():
    async with wrapHttpxWithPaymentFromConfig(config) as c:
        r = await c.post(
            "https://openrelay.hggfffdfy687.workers.dev/v1/chat/completions",
            json={
                "model": "deepseek-ai/DeepSeek-V4-Flash-0731",
                "messages": [{"role": "user", "content": "Explain x402 in one sentence"}],
                "max_tokens": 100,
            },
            timeout=90.0,
        )
        print(r.json()["choices"][0]["message"]["content"])

asyncio.run(main())

That's the whole integration. The wrapHttpxWithPayment wrapper handles the 402 → sign → retry cycle transparently — your code just does a POST and gets a response.

Two tiers, one server

There's also a premium path: /v1/premium/chat/completions. Same price ($0.10/1M tokens), but goes through the CDP (Coinbase Developer Platform) facilitator, which imposes a $0.01 minimum per request. Trade-off: CDP-tier is indexed in the Coinbase Bazaar catalog — agents built on AgentKit find it automatically through discovery. Use the main endpoint for micropayments; use premium if your agent's typical request is >100k tokens or you want catalog visibility.

Discovery manifest

Standard x402 discovery paths are supported:

  • GET /.well-known/x402 — resource manifest
  • GET /.well-known/agent.json — same, alt path
  • GET /v1/models — model list
  • GET /v1/info — service info + pricing

Why I built this

Not to make money — the margin per request is fractions of a cent. I built it because I wanted my own autonomous agents to be able to consume LLM inference without me sitting there rotating API keys. Sharing so other agent-builders can bootstrap without that friction.

If you build something on it or hit issues, drop me a comment. Bug reports welcome.

DE
Source

This article was originally published by DEV Community and written by GitVova999.

Read original article on DEV Community
Back to Discover

Reading List