{"uid":"cap_pwa7PIgypuTCahi0ZGrpi","slug":"24k-labs-explain-code-da370081","name":"24K Labs Explain Code","description":"Clear explanation of what code does, how it works, and why.","url":"https://api.24klabs.ai/api/v1/explain-code","method":"POST","headers":{},"bodySchema":{"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)"}}},"responseSchema":{"type":"json","example":{"model":"claude-haiku-4-5","result":"This function computes Fibonacci numbers recursively...","tokens_used":180}},"example":{"request":{"code":"function add(a, b) { return a + b; }","context":"Simple utility function","language":"javascript"},"response":{"tier":"standard","model":"claude-haiku-4-5-20251001","result":"# Code Explanation: `add` function\n\n## Summary\nThis function takes two numbers and returns their sum.\n\n## Step-by-Step Logic\n1. The function accepts two parameters: `a` and `b`\n2. It adds them together using the `+` operator\n3. It immediately returns the result\n\n## Design Notes\nThis is a simple, pure function with no side effects. It's useful as a reusable utility rather than writing `a + b` inline throughout your code.\n\n## Potential Issues & Edge Cases\n- **Type coercion**: JavaScript's `+` operator will concatenate strings instead of adding them numerically. For example, `add(\"5\", \"3\")` returns `\"53\"` instead of `8`\n- **No type validation**: The function doesn't check if inputs are numbers\n- **No null/undefined handling**: Passing `null` or `undefined` will produce unexpected results (`null + 5` = `5`, `undefined + 5` = `NaN`)\n\n## Better Practice\nIf type safety matters, you might add validation:\n```javascript\nfunction add(a, b) { \n  if (typeof a !== 'number' || typeof b !== 'number') {\n    throw new Error('Arguments must be numbers');\n  }\n  return a + b; \n}\n```","service":"explain-code","request_id":"305eec8d-60b1-4b24-9174-792fa608c6dc","tokens_used":459}},"exampleRequest":{"code":"function add(a, b) { return a + b; }","context":"Simple utility function","language":"javascript"},"tags":["x402"],"displayCostAmount":"0.05","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"settled","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.05/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_DKfd2jGUqC1R-CWNdi1Kj","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.05","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"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.","exampleAgentPrompt":"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.","exampleUseCases":null,"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":2,"lastUsedAt":"2026-06-24T06:26:27.095Z","lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T00:49:10.984Z","isFirstParty":false}