Catalog/llm-code-blocks

LLM

Extract code blocks API

Extracts every fenced code block (```lang … ```) from markdown with its language tag, and returns a per-language histogram — the reliable way to pull runnable code out of an LLM answer. Answers 'how do I get the code blocks from this markdown?', 'what languages are in this response?'.

Price$0.02per request
MethodPOST
Route/v1/llm/code-blocks
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
llmcodemarkdownextractfencedparsecode-blockagent
API URLhttps://x402.hexl.dev/v1/llm/code-blocks
Integration docs
Example request
{
  "markdown": "text\n```python\nprint(1)\n```\nmore\n```js\nx=1\n```"
}
Example response
{
  "count": 2,
  "blocks": [
    {
      "lang": "python",
      "code": "print(1)"
    },
    {
      "lang": "js",
      "code": "x=1"
    }
  ],
  "byLang": {
    "python": 1,
    "js": 1
  }
}
Input schema
{
  "type": "object",
  "required": [
    "markdown"
  ],
  "properties": {
    "markdown": {
      "type": "string",
      "examples": [
        "text\n```python\nprint(1)\n```\nmore\n```js\nx=1\n```"
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}