https://grid.x402compute.cc (the SDK adds /v1/messages itself)
You call Grid models (
qwen-2.5-32b, qwen-2.5-7b, …), never Claude models. List what is served right now with GET /v1/models and an anthropic-version header.Quickstart (cURL)
With the Anthropic SDKs
Streaming
message_start, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop, with ping while the node works and an error event if the stream fails after it started.
Endpoints
Authentication and payment
The same three ways as the OpenAI endpoint:x-api-key: x402c_...orAuthorization: Bearer x402c_...: billed to the key owner’s credits.Authorization: Bearer <session token>: billed to the signed-in account.X-Payment: <x402 payload>: pay per request. Without auth, the402body is an Anthropic error (billing_error) that also carries the x402 fields (x402Version,accepts,price_usd), so x402 clients work unchanged.
What works
model,messages,max_tokens,system(string or text blocks),stop_sequences,stream,temperature,tools,tool_choice(auto,any,tool,none).- Content blocks:
text,image(base64, vision models only, one image per request, non-streaming),tool_use,tool_result(text, withis_error). - Stop reasons:
end_turn,max_tokens,stop_sequence,tool_use,refusal. usage.input_tokensandusage.output_tokens. Cache token counts are always 0.usage.cost_usdis an extra field with the charge.- Errors use the Anthropic shape (
{"type":"error","error":{...},"request_id":...}) with arequest-idheader.
thinking of type adaptive, disabled or between_tools, output_config.effort, metadata, service_tier, cache_control (there is no prompt caching), and context_management edits that clear thinking. Earlier thinking blocks in a conversation are dropped, so a chat started on Claude can continue on the Grid.
What does not work
These return a clean400 invalid_request_error:
- Extended thinking with a budget, structured outputs (
output_config.format), strict tools. - Server tools and Anthropic-defined tools: web search, web fetch, code execution, bash, text editor, computer use, memory, tool search. Define your own tool with an
input_schemainstead. documentblocks (PDF or text), search results and citations.- Image URLs and Files API images (send base64), images inside
tool_result. mcp_servers,container,top_p,top_k, assistant prefill,max_tokens: 0,disable_parallel_tool_use: true.- Any other unknown top-level field. The Grid names it in the error instead of ignoring it.
Good to know
- Context windows are small. Each model serves the context its nodes run, often 4k to 16k tokens. Check
max_input_tokensin/v1/models. A prompt that leaves no room for a reply gets a400with the limit. Amax_tokensabove the room left is lowered to fit (thex-sgl-max-tokens-*headers report it), and output is capped at 8192 tokens. - Long replies: stream them. A non-streaming reply that runs past the sync window returns
504 timeout_errorwith thejob_idandx-should-retry: false, because a retry would start a second, separately billed job. - Stop sequences are applied by the Grid, not the node. The reply is cut at the first match, but the node keeps generating until it stops, and those tokens are billed.
- Tool call input arrives as one
input_json_deltaper call, once the call is complete and valid JSON. - Retries. The SDKs retry
429and5xxby default, which is safe: nothing is charged on those. Payment errors are sent withx-should-retry: false. - Privacy.
/v1/messagesuses the API path where the Grid seals your prompt to the node. The browser path where your own client seals the prompt has no Anthropic equivalent; see Confidential inference.
Related
Claude Code on the Grid
Run Claude Code against Grid models.
OpenAI-compatible API
The other API shape.
Models
What is served and how to choose.
