{"uid":"cap_rVTsBGByptaHQOwZK8-sx","slug":"grok-via-locus-x402-chat-completions-0b50aa25","name":"Grok via Locus x402 — Chat Completions","description":"xAI models — chat, web/X search, code execution, image generation/editing, and text-to-speech.","url":"https://grok.x402.paywithlocus.com/grok/chat","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"n":{"type":"number"},"stop":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"model":{"type":"string"},"top_p":{"type":"number"},"messages":{"type":"array","items":{"type":"object","required":["role"],"properties":{"name":{"type":"string"},"role":{"type":"string"},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","required":["type"],"properties":{"text":{"type":"string"},"type":{"type":"string"},"image_url":{"type":"object","required":["url"],"properties":{"url":{"type":"string"}},"additionalProperties":true}},"additionalProperties":true}},{"type":"null"}]},"tool_calls":{"type":"array","items":{"type":"object","additionalProperties":true}},"tool_call_id":{"type":"string"}},"additionalProperties":true}},"max_tokens":{"type":"number"},"temperature":{"type":"number"},"presence_penalty":{"type":"number"},"frequency_penalty":{"type":"number"}}},"responseSchema":{"type":"json","example":{"data":{},"payment":{"scheme":"exact","settledUsdc":"0.001000","authorizedMaxUsdc":"0.001000"},"request":{"id":"00000000-0000-4000-8000-000000000000","statusUrl":"/requests/00000000-0000-4000-8000-000000000000"},"success":true}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_Ot4jo5eOCkdZc_XZEDA93","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Send chat messages to xAI's Grok models (grok-4.5, grok-4.3, reasoning/non-reasoning variants) and receive completions, with per-call USDC micropayment via x402 protocol.","exampleAgentPrompt":"Use grok-4.5 to explain the trade-offs between transformer and state-space models in at most 300 tokens — keep the temperature at 0.7 and stop if you hit the phrase 'In conclusion'.","exampleUseCases":[{"title":"AI-powered code review assistant","prompt":"Ask Grok (use grok-4.3) to review this Python function for bugs and suggest improvements, give me up to 500 tokens of output at temperature 0.3: def fib(n): return n if n <= 1 else fib(n-1) + fib(n-2)"},{"title":"Reasoning through a complex math problem","prompt":"Use the grok-4.20-0309-reasoning model to solve this probability problem step by step, capped at 800 tokens: 'In a room of 30 people, what is the probability that at least two share a birthday?'"},{"title":"Multilingual customer support draft","prompt":"Have Grok (grok-4.5-latest) write a polite customer support reply in Spanish to a user who is frustrated their order hasn't arrived after 10 days — keep it under 200 tokens and professional in tone."}],"resultDescription":"A JSON object containing: a `data` field with the xAI chat completion payload (choices, message content, usage), a `payment` object showing the settled and authorized USDC amounts, a `request` object with a unique UUID and a status polling URL, and a boolean `success` flag.","failureModes":["Insufficient USDC balance or failed x402 payment authorization — returns payment failure error","Invalid or unsupported model ID provided — returns model not found or validation error","max_tokens not specified — required for metered billing; returns validation error","Token limit exceeded for the chosen model — returns context length error","Malformed messages array (wrong role values or content structure) — returns 400 bad request","Request timeout for long-running reasoning completions","Rate limiting if too many concurrent requests are submitted"],"whenToPreferThis":"Choose this endpoint when you need to call xAI's Grok models (especially grok-4.5 or reasoning variants) with a pay-per-call USDC micropayment model via the x402 protocol, avoiding API key subscriptions. Ideal for agents that need metered, on-demand Grok inference without committing to a monthly plan, or for decentralized agent pipelines that settle payments on-chain.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T12:39:13.029Z","isFirstParty":false}