Skip to content

x402 Gateway

The x402 Gateway provides direct HTTP access to OpenGradient's TEE verified LLM inference without requiring the Python SDK. Because x402 is a standard HTTP protocol, you can integrate from any language or platform - JavaScript, Go, Rust, Python, curl, or any HTTP client.

What is x402?

x402 is an open standard that extends HTTP with payment requirements using the 402 Payment Required status code. When you make a request to the x402 Gateway:

  1. The server responds with payment requirements
  2. You sign a payment authorization
  3. You resubmit the request with the signed payment
  4. The inference executes and payment settles on-chain

All LLM inferences are verified using TEE (Trusted Execution Environments), providing cryptographic proof of execution.

TIP

For a deep dive into how x402 works on OpenGradient, including TEE verification and settlement modes, see LLM Execution.

Quick Start

Prerequisites

  • An OpenGradient wallet with a private key (such as MetaMask)
  • OUSDC tokens on the OpenGradient network

Basic Flow

bash
# 1. Make initial request - get payment requirements
curl -X POST https://llmogevm.opengradient.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}],
    "max_tokens": 100
  }'

# Response: 402 Payment Required with payment details in headers

The server returns a 402 status with payment requirements. You then:

  1. Parse the payment requirements from the response headers
  2. Create and sign a payment payload with your wallet
  3. Resubmit the request with the X-PAYMENT header containing your signed payment

TIP

You can find x402 client libraries to automate these steps in Coinbase's x402 repo.

See Examples for complete implementations in multiple languages.

Endpoint

EnvironmentURL
Productionhttps://llmogevm.opengradient.ai

Supported Models

Model IDProvider
openai/gpt-4.1OpenAI
openai/gpt-4oOpenAI
anthropic/claude-4.0-sonnetAnthropic
anthropic/claude-3.5-haikuAnthropic
x-ai/grok-3-betaxAI
x-ai/grok-3-mini-betaxAI
x-ai/grok-4-1-fast-non-reasoningxAI
google/gemini-2.5-flash-previewGoogle
google/gemini-2.5-pro-previewGoogle

Payment Details

  • Currency: OUSDC (OpenGradient USDC, 0x48515A4b24f17cadcD6109a9D85a57ba55a619a6)
  • Chain ID: 10744 (OpenGradient network)

Payments are settled on-chain after inference execution. You can verify transactions on the OpenGradient block explorer.

Settlement Modes

Control how inference data is recorded on-chain by setting the X-SETTLE header:

ModeHeader ValueDescription
IndividualSETTLE_INDIVIDUALInput/output hashes only (default, most private)
With MetadataSETTLE_INDIVIDUAL_WITH_METADATAFull prompt and response data on-chain
BatchSETTLE_BATCHAggregated hashes for multiple inferences

Use SETTLE_INDIVIDUAL_WITH_METADATA when you need to prove which prompts were used for agent actions or decision verification.

When to Use x402 vs SDK

Use x402 directly when...Use Python SDK when...
Building in JavaScript, Go, Rust, etc.Building in Python
You want fine-grained control over paymentsYou want automatic payment handling
Integrating into existing HTTP infrastructureStarting a new Python project
Building a custom SDK for another languagePrototyping quickly

Next Steps