# Pipelex Documentation > Official documentation for Pipelex, an open-source library/CLI for building and running executable AI methods. # Get Started ## Build & Run AI Methods ![Pipelex Banner](https://d2cinlfp2qnig1.cloudfront.net/banners/pipelex_banner_docs_v2.png) # Build & Run AI Methods A method is a reusable, typed AI procedure — declared in a `.mthds` file and executed by Pipelex. Each step is explicit, each output is structured, and every run is repeatable. [:material-robot-outline: Claude Code](./get-started/build-with-claude-code.md){ .md-button .md-button--primary } [:material-school: MTHDS Tutorial](./get-started/mthds-language-tutorial.md){ .md-button } [:material-book-open-variant: Cookbook](./cookbook/index.md){ .md-button } --- ## Why Methods?
- :material-file-document-check: **Declarative** Express business logic at a high level of abstraction, in human-readable `.mthds` files that work across models. - :material-shape-outline: **Typed** Concepts are semantic types: AI understands what you mean, and every input and output connects with purpose. - :material-refresh: **Repeatable** Deterministic orchestration that leaves exactly the room you want for AI to express its intelligence and creativity. - :material-puzzle: **Composable** Chain pipes into sequences, nest methods inside methods, and share them with the community.
--- ## What a Method Looks Like A single pipe in MTHDS — five lines that call an LLM with typed inputs and output: ```toml [pipe.summarize_article] type = "PipeLLM" inputs = { article = "Text", audience = "Text" } output = "Text" prompt = "Summarize $article in three bullet points for $audience." ``` From here, Pipelex handles model routing across 60+ models, structured output parsing, and pipeline orchestration. --- ## Capabilities
- :material-shape-outline: **[Typed Concepts](./features/concepts.md)** Semantic types that give meaning to every input and output — native, inline, or backed by Python classes. - :material-pipe: **[Pipe Operators](./features/pipe-operators.md)** Operators that do the work: LLM calls, text structuring, document extraction, image generation, web search, composition, and custom functions. - :material-sitemap: **[Pipeline Orchestration](./features/pipeline-orchestration.md)** Sequence, parallel, batch, and conditional controllers that wire pipes into full methods with shared working memory. - :material-cloud-check: **[60+ AI Models](./features/llm-integration.md)** One gateway key or bring-your-own: OpenAI, Anthropic, Mistral, Google, Deepseek, Hugging Face, and more. - :material-check-decagram: **[Validation and Dry Run](./features/validation-dry-run.md)** Validate pipelines before execution and dry-run with mocked responses — catch errors without spending tokens. - :material-console: **[CLI and Tooling](./features/cli.md)** Full CLI for init, build, validate, run, and graph visualization. Plus `plxt` for formatting and linting `.mthds` files.
--- ## The MTHDS Ecosystem MTHDS is the open standard behind Pipelex methods. It defines the language, the file format, and the ecosystem for sharing methods. !!! info "Explore the ecosystem" - **[mthds.ai](https://mthds.ai/latest/)** — The MTHDS language specification - **[mthds.sh](https://mthds.sh)** — The Methods Hub for discovering and sharing methods - **[MTHDS Plugins](https://github.com/mthds-ai/mthds-plugins)** — Claude Code plugin for building, running, and validating methods --- ## Get Started
- :material-robot-outline: **[Build with Claude Code](./get-started/build-with-claude-code.md)** Describe what you want in natural language — Claude writes, runs, and iterates on your method for you. - :material-school: **[MTHDS Language Tutorial](./get-started/mthds-language-tutorial.md)** Learn the declarative language step by step: concepts, pipes, sequences, inputs, and structured outputs. - :material-book-open-variant: **[Cookbook Examples](./cookbook/index.md)** Production-ready recipes — from Hello World to document extraction, synthetic data, and image generation.
## Build with Claude Code # Build with Claude Code Install the `mthds` CLI: ```bash npm install -g mthds ``` Launch Claude Code and tell it to install the MTHDS plugin: ``` /plugin marketplace add mthds-ai/mthds-plugins ``` ``` /plugin install mthds@mthds-plugins ``` then reload plugins: ``` /reload-plugins ``` If that doesn't work, exit Claude Code and reopen it: ``` /exit ``` Build your first method: ``` /mthds-build A method to analyze a Job offer to build a scorecard, then batch process CVs to score them ``` Run it: ``` /mthds-run ``` That's it — Claude writes the `.mthds` file, creates inputs, and runs the method for you. See the [Claude Code Skills Plugin](../features/claude-code-skills-plugin.md) documentation for the full list of commands (`/mthds-edit`, `/mthds-check`, `/mthds-fix`, `/mthds-explain`, and more). See [Configure AI Providers](./configure-ai-providers.md) for other options: bring your own keys, local AI, etc. ![Claude Code + Pipelex + MTHDS](https://raw.githubusercontent.com/Pipelex/pipelex/main/.github/assets/Claude-Code-Pipelex-MTHDS-Cursor.png) ## The MTHDS Language Tutorial # The MTHDS Language Tutorial This tutorial walks you through writing `.mthds` files manually, step by step. Set up your project and get free AI access: ```bash uv tool install pipelex pipelex init pipelex login ``` `pipelex init` creates your project configuration. `pipelex login` opens your browser to authenticate with Pipelex Gateway (free). See [Configure AI Providers](./configure-ai-providers.md) for other options: bring your own keys, local AI, etc. !!! tip "VS Code Extension" We **highly** recommend installing the Pipelex extension for `.mthds` syntax highlighting and flowchart visualization: - **VS Code**: Install from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=pipelex.pipelex) - **Cursor, Windsurf, and other VS Code forks**: Install from the [Open VSX Registry](https://open-vsx.org/extension/Pipelex/pipelex) Running `pipelex init` will also offer to install the extension automatically if it detects your IDE. ## Step 1: Hello World Create a file called `hello_world.mthds`: ```toml domain = "tutorial_hello_world" description = "Your first Pipelex pipeline" main_pipe = "tutorial_hello_world" [pipe] [pipe.tutorial_hello_world] type = "PipeLLM" description = "Generate a creative story idea" output = "Text" prompt = """ Generate a one-paragraph creative story idea about a robot learning to paint. """ ``` Run it: ```bash pipelex run bundle hello_world.mthds ``` Here's what each part means: - **`domain`** — a namespace for this bundle (like a Python package name) - **`main_pipe`** — the entry point pipe that runs when you execute the bundle - **`PipeLLM`** — a pipe type that makes an LLM call - **`output = "Text"`** — the pipe returns plain text (a native concept) - **`prompt`** — the prompt sent to the LLM ## Step 2: Chaining LLM Calls Most real methods need multiple steps. `PipeSequence` chains pipes together, passing data between them. Create `chaining_llm_calls.mthds`: ```toml domain = "chaining_llm_calls" description = "Chain multiple LLM calls together" main_pipe = "generate_and_expand" [pipe] # First pipe: Generate a story idea [pipe.chain_generate_idea] type = "PipeLLM" description = "Generate a creative story idea" output = "Text" prompt = """ Generate a one-paragraph creative story idea about a robot learning to paint. """ # Second pipe: Expand the story idea (uses result from first pipe) [pipe.chain_expand_idea] type = "PipeLLM" description = "Expand a story idea into a detailed outline" inputs = { story_idea = "Text" } output = "Text" prompt = """ Take this story idea and expand it into a 3-act outline: @story_idea Provide a brief description for each act. """ # PipeSequence: Chain the two pipes together [pipe.generate_and_expand] type = "PipeSequence" description = "Generate a story idea then expand it" output = "Text" steps = [ { pipe = "chain_generate_idea", result = "story_idea" }, { pipe = "chain_expand_idea", result = "story_outline" }, ] ``` Run it: ```bash pipelex run bundle chaining_llm_calls.mthds ``` Key concepts: - **`PipeSequence`** — runs pipes in order, passing results between them - **`steps`** — each step names a pipe and stores its output in a `result` variable - **`@story_idea`** — references data from a previous step's result in the prompt ## Step 3: Using Inputs Instead of hardcoding everything in the prompt, you can pass data in at runtime. Create `using_inputs.mthds`: ```toml domain = "using_inputs" description = "Learn how to pass inputs to your pipeline" main_pipe = "write_about_topic" [pipe] # A pipe that takes an input and uses it [pipe.write_about_topic] type = "PipeLLM" description = "Write a short paragraph about a given topic" inputs = { topic = "Text" } output = "Text" prompt = """ Write a short, engaging paragraph about the following topic: $topic Keep it under 100 words. """ ``` Create an `inputs.json` file: ```json { "topic": "Photosynthesis" } ``` Run it with the `-i` flag: ```bash pipelex run bundle using_inputs.mthds -i inputs.json ``` Key concepts: - **`inputs = { topic = "Text" }`** — declares what the pipe expects as input - **`$topic`** — inserts the variable inline, right inside a sentence. The difference from `@variable` is rendering shape, not where the data comes from: `@variable` is the block form — it must sit alone on its own line and inserts the content as a tagged block (which is why `@story_idea` stood on its own line in Step 2) — while `$variable` is the inline form for weaving a value into surrounding text. Both resolve against the pipe's declared inputs - **`@@` and `$$`** — write a literal `@` or `$` without triggering interpolation. Use `@@font-face` or `@@media` inside `