# x402engine Grok Code LLM API

> x402engine Grok Code LLM API is a paid API for AI agents from x402engine.app, paid per call via x402, $0.015149/call, status unknown (last checked 2026-10-29).

Send chat messages to xAI's Grok code-focused model via HTTP 402 micropayment, returning an OpenAI-compatible response

## Facts

- Endpoint: POST https://x402engine.app/api/llm/grok-code?utm_source=zero.xyz
- Price: $0.015149/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-29
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402engine-grok-code-llm-api-9427ec7e
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_j3J1I6ZUYHXHIJOt0-Zc-

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability x402engine-grok-code-llm-api-9427ec7e -d '<json body>'
```

Example prompt: Use the Grok code model to write a Python function that parses a CSV file, groups rows by a date column, and returns the sum of a numeric column per group — include type hints and a docstring.

## When to prefer this

Choose this endpoint when you need a coding-specialized LLM (xAI Grok code variant) without a subscription, paying only $0.015 per call via USDC micropayment. Ideal for agents that need on-demand code generation, debugging, or code review without managing API keys or rate limits. Prefer over generic chat models when the task is code-centric and you want Grok's code-tuned reasoning.

## Known failure modes

- Payment not settled — 402 response if USDC/USDm payment fails or is insufficient
- Missing required 'messages' field — validation error
- Model context length exceeded if conversation history is too long
- Tool call loop if function results are not returned correctly via role=tool
- Streaming timeout if SSE connection drops mid-response
- Unsupported parameter (e.g. seed or logprobs) if model capability not listed in /docs/llm-capabilities.md

## How this service works

x402engine — xAI's build-focused model — code generation, analysis, and agentic implementation work

## Output

An OpenAI-compatible JSON response containing the model name ('x-ai/grok-build-0.1'), an array of choices each with an index, finish_reason, and message object (role + content), plus a top-level content field with the assistant's reply text. When streaming is enabled, returns SSE chunks in OpenAI format after payment settles.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "bodyType",
    "body",
    "method"
   ],
   "properties": {
    "body": {
     "type": "object",
     "required": [
      "messages"
     ],
     "properties": {
      "seed": {
       "type": "integer",
       "description": "Model-supported seed; see /docs/llm-capabilities.md."
      },
      "tools": {
       "type": "array",
       "items": {
        "type": "object",
        "required": [
         "function"
        ],
        "properties": {
         "type": {
          "enum": [
           "function"
          ],
          "type": "string"
         },
         "function": {
          "type": "object",
          "properties": {
           "name": {
            "type": "string"
           },
           "strict": {
            "type": "boolean"
           },
           "parameters": {
            "type": "object"
           },
           "description": {
            "type": "string"
           }
          }
         }
        }
       },
       "description": "Client-executed function definitions; return results using role=tool and tool_call_id."
      },
      "top_p": {
       "type": "number",
       "description": "Model-supported top_p; see /docs/llm-capabilities.md."
      },
      "stream": {
       "type": "boolean",
       "description": "Return live OpenAI-compatible SSE after payment settlement."
      },
      "plugins": {
       "type": "array",
       "items": {
        "type": "object",
        "required": [
         "pdf"
        ],
        "properties": {
         "id": {
          "enum": [
           "file-parser"
          ],
          "type": "string"
         },
         "pdf": {
          "type": "object",
          "properties": {
           "engine": {
            "enum": [
             "native"
            ],
            "type": "string"
           }
          }
         }
        }
       },
       "description": "Optional native PDF parser only; automatically enabled for file inputs."
      },
      "logprobs": {
       "type": "boolean",
       "description": "Model-supported logprobs; see /docs/llm-capabilities.md."
      },
      "messages": {
       "type": "array",
       "items": {
        "type": "object",
        "anyOf": [
         {
          "required": [
           "content"
          ]
         },
         {
          "
… (truncated)
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "model": "x-ai/grok-build-0.1",
  "choices": [
   {
    "index": 0,
    "message": {
     "role": "assistant",
     "content": "Hello!"
    },
    "finish_reason": "stop"
   }
  ],
  "content": "Hello!"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402engine-grok-code-llm-api-9427ec7e/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402engine.app](https://www.zero.xyz/host/x402engine.app/llms.txt)
