# Grok Code (x402 Gateway)

> Grok Code (x402 Gateway) is a paid API for AI agents from x402-gateway-production.up.railway.app, paid per call via x402, $0.040000/call, status unknown (last checked 2026-10-11, last successful call 2026-05-15).

Calls xAI's Grok code-specialized model for fast code generation, analysis, and technical tasks via x402 micropayment gateway

## Facts

- Endpoint: POST https://x402-gateway-production.up.railway.app/api/llm/grok-code?utm_source=zero.xyz
- Price: $0.040000/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-11
- Last successful call: 2026-05-15
- Success rate: 50% of calls made through Zero
- Rating: 4.0 / 5 from 1 review
- Activations on Zero: 2
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402-gateway-production-up-railway-app-912d5e80
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_WMZr0Lzgjg3QJfSD_o4Fn

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 x402-gateway-production-up-railway-app-912d5e80 -d '<json body>'
```

Example prompt: Write me a Python function that takes a list of integers and returns all pairs that sum to a target value, with O(n) time complexity and include docstrings and edge case handling.

## When to prefer this

Choose this endpoint when you need fast, code-focused AI generation or analysis and want to pay per call without a subscription. Prefer over general-purpose LLMs when the task is predominantly code (generation, debugging, refactoring, explanation). Prefer over Mistral Codestral sibling if you specifically want xAI's Grok model characteristics. Best for agentic workflows where code tasks are dynamic and billing should be usage-based via USDC micropayments.

## Known failure modes

- Payment failure — insufficient USDC balance or x402 payment rejected, returns 402 Payment Required
- Invalid or missing prompt — returns 400 Bad Request
- Model timeout for very long or complex code generation requests
- Rate limiting if too many requests are sent in rapid succession
- Ambiguous prompt may produce syntactically correct but logically incorrect code

## How this service works

xAI's code-specialized model — fast code generation and analysis

## Output

Returns AI-generated code, code explanations, debugging suggestions, or technical analysis from xAI's Grok model optimized for code tasks. Output is typically structured as the model's text response containing code blocks, inline explanations, and/or step-by-step reasoning.

## 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)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402-gateway-production-up-railway-app-912d5e80/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402-gateway-production.up.railway.app](https://www.zero.xyz/host/x402-gateway-production.up.railway.app/llms.txt)
