{"uid":"cap_YvbvdMZbLypzZs9BJbX5j","slug":"x402-ai-apis-xai-chat-completions-9ec2b190","name":"x402 AI APIs – xAI Chat Completions","description":"Paid AI API endpoints via x402 micropayments","url":"https://x402-ai-peach.vercel.app/api/xai","method":"POST","headers":{},"bodySchema":{"type":"object","required":["messages"],"properties":{"stream":{"type":"boolean","description":"Stream response"},"messages":{"type":"array","description":"Chat messages array"},"max_tokens":{"type":"integer","description":"Max tokens"},"temperature":{"type":"number","description":"Temperature"}}},"responseSchema":{"type":"object","properties":{"id":{"type":"string","description":"Response ID"},"choices":{"type":"array","items":{"type":"object","properties":{"message":{"type":"object","properties":{"role":{"type":"string"},"content":{"type":"string"}}}}}}}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.125","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"registry","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.125/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.125","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.125","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_9yuBrcbZZHYCFuI3vMW5m","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.125","costPer":"request","priority":0,"asset":null,"unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Provides paid chat completions via xAI's language model, billed per-call through x402 micropayments","exampleAgentPrompt":"Ask xAI to summarize the pros and cons of switching from PostgreSQL to MongoDB — send up to 500 tokens, with a temperature of 0.7, and don't stream the response.","exampleUseCases":[{"title":"Pay-per-call AI coding assistant","prompt":"Use the xAI API to explain what this Python function does and suggest improvements — keep the response under 300 tokens and use a low temperature of 0.2 so the answer is precise."},{"title":"On-demand content generation for agents","prompt":"I need xAI to draft a short marketing tagline for my new fitness app called 'PaceUp' — pay per call, max 150 tokens, temperature around 0.9 for creativity."},{"title":"Structured Q&A with Grok model","prompt":"Send these three user messages to the xAI chat API and get back an answer explaining quantum entanglement in simple terms — limit to 400 tokens, temperature 0.5, no streaming."}],"resultDescription":"Returns a JSON object with a response ID and a choices array, where each choice contains an assistant message with a role and content string — the generated text from the xAI model.","failureModes":["402 Payment Required if x402 micropayment header is missing or insufficient","400 Bad Request if messages array is missing or malformed","timeout or partial response if max_tokens is very large","streaming errors if stream:true is set but client doesn't handle chunked responses","model unavailability resulting in 503 errors"],"whenToPreferThis":"Choose this endpoint when you need xAI (Grok) chat completions on a pay-per-call basis via x402 USDC micropayments, without committing to a subscription — ideal for agents making infrequent or unpredictable LLM calls that need per-use billing transparency.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T06:41:02.455Z","isFirstParty":false}