# 24K Labs Explain Code

> 24K Labs Explain Code is a paid API for AI agents from api.24klabs.ai, paid per call via x402, $0.05/call, status unknown (last checked 2026-09-15).

Accepts a code snippet and returns a plain-English explanation of what the code does, powered by Claude AI, billed per request in USDC on Base L2.

## Facts

- Endpoint: POST https://api.24klabs.ai/api/v1/explain-code
- Price: $0.05/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 2
- Tags: x402
- Canonical page: https://www.zero.xyz/c/24k-labs-explain-code-da370081
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_pwa7PIgypuTCahi0ZGrpi

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 24k-labs-explain-code-da370081 -d '<json body>'
```

Example prompt: Can you explain what this JavaScript function does: `function fib(n) { return n <= 1 ? n : fib(n-1) + fib(n-2); }` — give me a plain English explanation using 24K Labs.

## When to prefer this

Choose this endpoint when you need a quick, per-request AI-powered explanation of a code snippet without committing to a subscription or managing API keys — ideal for agents or apps that occasionally need code explanation and want to pay only for what they use via USDC on Base L2.

## Known failure modes

- Missing or empty `code` parameter returns an error
- Unsupported or ambiguous language may reduce explanation quality
- Payment failure (insufficient USDC on Base L2) results in 402 response
- Very large code snippets may exceed token limits
- Network timeout for unusually complex or long inputs

## How this service works

Clear explanation of what code does, how it works, and why.

## Output

A JSON response containing the model used (e.g. claude-haiku-4-5), a natural language explanation of the provided code snippet, and the number of tokens consumed.

## Example request

```json
{
 "code": "function add(a, b) { return a + b; }",
 "context": "Simple utility function",
 "language": "javascript"
}
```

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "code": {
   "type": "string",
   "description": "Primary input content"
  },
  "context": {
   "type": "string",
   "description": "Optional context or instructions"
  },
  "language": {
   "type": "string",
   "description": "Programming language (code services)"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "model": "claude-haiku-4-5",
  "result": "This function computes Fibonacci numbers recursively...",
  "tokens_used": 180
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/24k-labs-explain-code-da370081/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.24klabs.ai](https://www.zero.xyz/host/api.24klabs.ai/llms.txt)
