Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nayalsaurav/ai360/llms.txt
Use this file to discover all available pages before exploring further.
The Code Explainer endpoint accepts any code snippet and returns a step-by-step, beginner-friendly explanation powered by Google’s Gemini 2.5 Flash model. The system prompt instructs the model to explain code in plain English, walking through each step in a way that is accessible to developers at any level. Any programming language is supported.
Request
POST /api/utilities/code-explainer
Content-Type: application/json
The code snippet you want explained. Can be any valid code in any programming
language. Include the complete snippet for best results — partial code may
produce incomplete or context-lacking explanations.
Response
A successful request returns HTTP 200 with the following body:
A step-by-step, plain-language explanation of the submitted code, generated
by Gemini 2.5 Flash. The explanation walks through the logic sequentially
using beginner-friendly terminology.
{
"explanation": "This code defines a function called `add` that takes two numbers as input and returns their sum. Here's a step-by-step breakdown:\n\n1. **Function declaration** — `function add(a, b)` creates a reusable block of code named `add`..."
}
Error Responses
| Status | Body | Cause |
|---|
400 | { "error": "Missing code snippet." } | userPrompt was absent or empty. |
500 | { "error": "Failed to explain code." } | Gemini API call failed or an unexpected server error occurred. |
Always include userPrompt in the request body. An absent or empty value
returns 400 immediately without invoking the AI model.
The model is prompted to explain code “step by step in simple, beginner-friendly
terms.” If you need a more technical deep-dive, consider including that
instruction directly in the code snippet as a comment.
Example
Request
curl -X POST https://your-domain.com/api/utilities/code-explainer \
-H "Content-Type: application/json" \
-d '{
"userPrompt": "function fibonacci(n) {\n if (n <= 1) return n;\n return fibonacci(n - 1) + fibonacci(n - 2);\n}"
}'
Response
{
"explanation": "This code defines a recursive function called `fibonacci` that calculates the nth Fibonacci number. Here's how it works step by step:\n\n1. **Function definition** — `function fibonacci(n)` creates a function that accepts one argument, `n`, representing which Fibonacci number you want.\n\n2. **Base case** — `if (n <= 1) return n` stops the recursion. If `n` is 0, it returns 0; if `n` is 1, it returns 1. These are the first two numbers in the Fibonacci sequence.\n\n3. **Recursive case** — `return fibonacci(n - 1) + fibonacci(n - 2)` calls the function twice with smaller values and adds the results together. This mimics the Fibonacci rule: each number is the sum of the two before it.\n\n4. **How it unfolds** — Calling `fibonacci(4)` expands to `fibonacci(3) + fibonacci(2)`, which further expands until all calls hit the base case and return 0 or 1."
}