Build paid API access with Grok Build
Use this guide when Grok Build is helping you add Hilt Pay API to an API, AI tool, bot, dataset, paid software feature, or private endpoint. The public example is a complete Next.js application, not only a prompt. It contains:- a protected server route
- Hilt entitlement checks
- HTTP
402 Payment Requiredresponses - Hilt Pay API payment-session creation
- local, sandbox, and live modes
- a server-only development confirmation route
- signed webhook verification
- route-flow tests
AGENTS.mdinstructions and a Grok project skill
Hilt and Grok Build are separate products. This guide documents compatibility with Grok Build’s public agent instructions, project skills, headless mode, and MCP support. It does not describe an xAI partnership.
What each product does
Current public live settlement is Solana USDC. x402 is the HTTP
402 Payment Required protected-resource protocol shape. It is not a blockchain, token, wallet, chain, or settlement rail.
1. Install Grok Build
Use the official Grok Build installer for your operating system. macOS, Linux, or WSL:https://docs.x.ai/build/overview
2. Get the runnable Hilt example
3. Run without a Hilt key
The defaultlocal mode proves the application control flow without moving money or claiming a Hilt receipt.
macOS, Linux, or WSL:
http://localhost:3000 and complete this flow:
- Request the protected report.
- Confirm that the server returns HTTP 402.
- Confirm that the response says
payment_protocol: "x402"andsettlement_rail: "solana_usdc". - Run the clearly labelled local confirmation.
- Retry the protected route.
- Confirm that the route serves the report only after the entitlement becomes active.
4. Let Grok inspect the contract
From the example directory:AGENTS.md file and the hilt-pay-api project skill. Use this prompt:
PROMPT.md to Grok Build and requests JSON output. It does not pass Hilt credentials in the prompt.
5. Choose the right mode
Hilt sandbox mode
Create a Hilt Pay API sandbox product, then update.env.local:
Live mode
After the owner has approved live setup, billing, payout wallet configuration, live API key scopes, and webhook configuration:409 in live mode. The buyer or buyer-agent must complete the real payment path. Your server then checks Hilt entitlement again before serving the protected resource.
Implementation contract
The entitlement check is the access decision. Do not serve paid work from a wallet signature, transaction hash, client claim, pending payment session, or webhook alone.Optional Agentverse discovery in Grok Build
Hilt can also be discovered through its Agentverse presence. Agentverse is an optional discovery path for Grok. Grok Build can connect to Agentverse MCP Lite because Grok supports remote MCP servers. This is optional. Agentverse helps the coding agent discover and inspect marketplace agents; it is not the Hilt Pay API transport and it is not required for the runnable example. macOS, Linux, or WSL:.grok/config.toml, AGENTS.md, prompts, or source code.
Verify the build
- missing customer identity is rejected
- unpaid access returns HTTP 402
- the response separates x402 protocol from Solana USDC settlement
- the local flow cannot be confused with a live payment
- a session cannot be confirmed for a different customer
- protected content is served only after entitlement is active
- API keys and sandbox proofs do not appear in browser responses
Before live traffic
- use a server-only Hilt API key with the required scopes
- configure the correct Hilt Pay API product and Solana payout wallet
- use a fresh attempt id for each logical checkout attempt
- verify Hilt webhooks against the raw body and
X-Hilt-Signature - store processed webhook event ids durably and process events idempotently
- complete sandbox validation
- let the owner approve live keys, billing, payout wallet configuration, and live use
- test the denied -> 402 -> payment -> entitlement -> retry loop
Related resources
- Hilt Agent Builder Kit
- Agent setup
- Hilt Pay API
- Testing
- Webhooks
- SDKs and Postman
https://www.hilt.so/.well-known/hilt-agent.jsonhttps://api.hilt.so/v1/openapi.json

