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 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)
OUSDCtokens on the OpenGradient network
Basic Flow
# 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 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://llmogevm.opengradient.ai |
Supported Models
| Model ID | Provider |
|---|---|
openai/gpt-4.1 | OpenAI |
openai/gpt-4o | OpenAI |
anthropic/claude-4.0-sonnet | Anthropic |
anthropic/claude-3.5-haiku | Anthropic |
x-ai/grok-3-beta | xAI |
x-ai/grok-3-mini-beta | xAI |
x-ai/grok-4-1-fast-non-reasoning | xAI |
google/gemini-2.5-flash-preview | |
google/gemini-2.5-pro-preview |
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:
| Mode | Header Value | Description |
|---|---|---|
| Individual | SETTLE_INDIVIDUAL | Input/output hashes only (default, most private) |
| With Metadata | SETTLE_INDIVIDUAL_WITH_METADATA | Full prompt and response data on-chain |
| Batch | SETTLE_BATCH | Aggregated 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 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
