{"uid":"cap_WLsAX5MpiUbxkqDXLREeY","slug":"24k-labs-ai-code-explainer-eb6e8e84","name":"24K Labs AI Code Explainer","description":"Clear explanation of what code does, how it works, and why.","url":"https://api.24klabs.ai/api/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":"def calculate_sum(numbers):\n    total = 0\n    for num in numbers:\n        total += num\n    return total","context":"This is a simple utility function","language":"python"},"response":{"tier":"standard","model":"claude-haiku-4-5-20251001","result":"# Code Explanation: `calculate_sum`\n\n## Summary\nThis function takes a list of numbers and returns their sum by adding each number together.\n\n## Step-by-Step Logic\n\n1. **Initialize a counter**: `total = 0` creates a variable to accumulate the sum, starting at zero\n2. **Loop through each number**: The `for num in numbers:` loop iterates through every element in the input list\n3. **Add to the total**: `total += num` adds the current number to the running total\n4. **Return the result**: After the loop completes, the function returns the final sum\n\n## Example\n```python\ncalculate_sum([1, 2, 3, 4])\n# Loop iteration 1: total = 0 + 1 = 1\n# Loop iteration 2: total = 1 + 2 = 3\n# Loop iteration 3: total = 3 + 3 = 6\n# Loop iteration 4: total = 6 + 4 = 10\n# Returns: 10\n```\n\n## Potential Issues & Edge Cases\n\n- **Empty list**: If `numbers` is empty, the function returns `0`, which is correct behavior\n- **Non-numeric values**: If the list contains non-numeric types (strings, None, etc.), the function will crash with a `TypeError`\n- **Performance**: For very large lists, this approach is fine. Python's built-in `sum()` function would be more concise: `return sum(numbers)`\n\n## Note\nThis is a basic implementation. In practice, you'd typically use Python's built-in `sum()` function instead: `sum(numbers)`","service":"explain-code","request_id":"5f102421-79af-4094-8a1e-e79634659488","tokens_used":555}},"exampleRequest":{"code":"def calculate_sum(numbers):\n    total = 0\n    for num in numbers:\n        total += num\n    return total","context":"This is a simple utility function","language":"python"},"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_ExkBNbrcz4B56Jxq6JoKB","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":"Explains what a given code snippet does using an AI model, returning a plain-language description","exampleAgentPrompt":"Can you explain what this Python function does? Here's the code: `def fib(n): return n if n <= 1 else fib(n-1) + fib(n-2)` — language is Python, no extra context needed.","exampleUseCases":null,"resultDescription":"A JSON object containing the AI model used (e.g. claude-haiku-4-5), a plain-language explanation of what the code does, and the number of tokens consumed in generating the response.","failureModes":["Missing or empty 'code' parameter returns an error","Unsupported or ambiguous language causes degraded explanation quality","Very large code snippets may hit token limits","Payment not received causes 402 response before processing","Malformed JSON in request body returns 400"],"whenToPreferThis":"Choose this endpoint when you need a quick, pay-per-use AI explanation of a code snippet without committing to a subscription or managing API keys — especially useful in agentic pipelines where on-demand code understanding is needed and USDC micropayments on Base L2 are already available.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T00:52:47.337Z","isFirstParty":false}