AI 代码解释器
AI & Agents粘贴任意代码片段,由 LLM 给出通俗易懂的解释——可选初学者、开发者或专家深度——使用你自己的免费 Groq 密钥,直接在浏览器中完成。
Detected: text · input capped at 12000 characters
此工具使用你自己的免费 API 密钥调用 Groq —— 只需在此浏览器中保存一次:
Your key stays in this browser (localStorage) and is sent only to api.groq.com — never to CosmoDev servers. Get a free Groq key
粘贴代码并点击“解释”查看讲解。(文档为英文)
AI Code Explainer
What it does
Explains a pasted code snippet in plain language, at the depth you pick: Beginner (no jargon, one analogy, step by step), Developer (what it does, the flow, the patterns, the pitfalls), or Expert (invariants, complexity, edge cases — the things a reviewer would flag). The tool detects the language first (Go, Rust, Python, SQL, TypeScript, JavaScript, CSS, HTML) and tells the model, so the explanation starts from the right place.
This is an AI Studio tool: it calls the model directly from your browser with your own free Groq API key. Nothing passes through CosmoDev servers, and we store nothing.
How to use
- Save your free Groq API key once — the panel keeps it in this browser’s localStorage. Get a key at console.groq.com/keys.
- Paste a snippet (up to 12,000 characters — longer inputs are truncated).
- Pick a depth: Beginner, Developer, or Expert.
- Press Explain code, then copy the result.
The hint under the input shows the detected language as you paste.
Examples
Input with depth = Developer:
msgs := []string{"a", "b"}
for i, m := range msgs {
fmt.Println(i, m)
}
Output (abridged): creates a slice of two strings, iterates with range which yields index and value per iteration, prints each pair — the idiomatic Go replacement for a C-style loop.
With depth = Beginner the same snippet is explained without words like “slice” or “range” being assumed — what they mean comes first.
Good to know
- Key custody: your key lives only in this browser (localStorage, namespaced
cosmodev:aistudio.groq) and is sent only toapi.groq.comas a request header — never to CosmoDev, never in a URL. The key panel has a Remove key button that wipes it. - Free tier: Groq’s free tier makes this genuinely free — see /ai-studio for every BYO-key tool and your key status.
- Rate limits: if Groq rate-limits the call (HTTP 429), the tool stops and shows the error with a manual Retry button — it never retries automatically.
- Detection is cheap: language detection is keyword heuristics, not a parser — it only steers the prompt. If it says the wrong language, the model usually recovers; you can also just trust the explanation.
- Privacy: your code goes only from your browser to Groq. CosmoDev has no backend in the path — the same egress model as every AI Studio tool. Still, don’t paste secrets.