# x402 AI Gateway - Code Explain

> x402 AI Gateway - Code Explain is a paid API for AI agents from x402-ai-gateway-rosy.vercel.app, paid per call via x402, $0.03/call, status unknown (last checked 2026-10-13).

Explains a given code snippet in plain language using Gemini 2.0 Flash, paid per-call with USDC on Base or Solana.

## Facts

- Endpoint: POST https://x402-ai-gateway-rosy.vercel.app/api/code-explain?utm_source=zero.xyz
- Price: $0.03/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-13
- Activations on Zero: 1
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402-ai-gateway-code-explain-b1bc7c83
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_lXYgYKWZlWvb-0-An0369

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-ai-gateway-code-explain-b1bc7c83 -d '<json body>'
```

Example prompt: Can you explain what this Python code does in plain English? Here's the snippet: `def fib(n): return n if n <= 1 else fib(n-1) + fib(n-2)`

## When to prefer this

Choose this endpoint when you need a fast, AI-generated natural language explanation of a code snippet and are already operating in a crypto-native (x402) payment environment using USDC on Base or Solana. Ideal for developer tools, code review assistants, or educational applications where per-call micropayment billing is acceptable.

## Known failure modes

- Missing required 'code' field returns validation error
- Empty code string may return unhelpful or generic explanation
- Unsupported or ambiguous language may reduce explanation quality
- Payment failure (insufficient USDC balance or wrong network) blocks the call
- Very long code snippets may hit token limits or time out

## How this service works

AI-powered API endpoints powered by Gemini 2.0 Flash. Pay with USDC on Base or Solana.

## Output

A plain-language explanation of the submitted code snippet, describing what it does, how it works, and any notable logic or patterns, generated by Gemini 2.0 Flash.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "code"
 ],
 "properties": {
  "code": {
   "type": "string"
  },
  "language": {
   "type": "string"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object"
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402-ai-gateway-code-explain-b1bc7c83/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402-ai-gateway-rosy.vercel.app](https://www.zero.xyz/host/x402-ai-gateway-rosy.vercel.app/llms.txt)
