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:
- The server responds with payment requirements
- You sign a payment authorization
- You resubmit the request with the signed payment
- The inference executes, payment settles on Base Sepolia, and proofs settle on the OpenGradient network
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
- A wallet with a private key (such as MetaMask)
$OPGtestnet tokens on Base Sepolia (get tokens from the faucet)
Basic Flow
# 1. Make initial request - get payment requirements
curl -X POST https://llm.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 headersThe server returns a 402 status with payment requirements. You then:
- Parse the payment requirements from the response headers
- Create and sign a payment payload with your wallet
- Resubmit the request with the
X-PAYMENTheader 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
| Environment | URL |
|---|---|
| Production | https://llm.opengradient.ai |
Supported Models
| Model ID | Provider |
|---|---|
openai/gpt-4.1-2025-04-14 | OpenAI |
openai/gpt-4o | OpenAI |
openai/o4-mini | OpenAI |
anthropic/claude-4.0-sonnet | Anthropic |
anthropic/claude-3.7-sonnet | Anthropic |
anthropic/claude-3.5-haiku | Anthropic |
google/gemini-2.5-flash | |
google/gemini-2.5-pro | |
google/gemini-2.5-flash-lite | |
google/gemini-2.0-flash | |
x-ai/grok-3-beta | xAI |
x-ai/grok-3-mini-beta | xAI |
x-ai/grok-4.1-fast | xAI |
x-ai/grok-4-1-fast-non-reasoning | xAI |
x-ai/grok-2-1212 | xAI |
x-ai/grok-2-vision-latest | xAI |
Payment Details
x402 LLM inference is paid for using $OPG testnet tokens on Base Sepolia. All other operations — TEE node registration, inference execution, proof settlement, and verification — happen on the OpenGradient network.
| Property | Value |
|---|---|
| Payment Network | Base Sepolia |
| Token | $OPG (0x240b09731D96979f50B2C649C9CE10FcF9C7987F) |
| Chain ID | 84532 |
| Proof Settlement | OpenGradient Network |
Payments are settled on Base Sepolia after inference execution. Inference proofs are settled separately on the OpenGradient network. You can get $OPG testnet tokens from the faucet.
Settlement Modes
Control how inference data is recorded on the OpenGradient blockchain by setting the X-SETTLEMENT-TYPE header:
| Mode | Header Value | Description |
|---|---|---|
| Private | private | No on-chain data, most private |
| Individual | individual | Input/output hashes on-chain |
| Batch | batch | Aggregated hashes for multiple inferences (default) |
NOTE
The SDK uses og.x402SettlementMode.SETTLE, og.x402SettlementMode.SETTLE_METADATA, and og.x402SettlementMode.SETTLE_BATCH as aliases for these values.
Use individual (or og.x402SettlementMode.SETTLE_METADATA in the SDK) 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 payments | You want automatic payment handling |
| Integrating into existing HTTP infrastructure | Starting a new Python project |
| Building a custom SDK for another language | Prototyping quickly |
Next Steps
- API Reference - Complete HTTP API documentation
- Examples - Integration examples in multiple languages
- LLM Execution - How x402 and TEE verification work
