Building an agent? Use the SDK.
OpenAI-compatible API. Point any OpenAI SDK athttps://api.morphllm.com/v1 — call an open-weight model directly, or use the SDK’s specialized tools for editing, search, compression, and classification. One key for everything.
Run an open-weight model
GLM-5.2 at 1M context. Change themodel string, nothing else.
Catch failures with Reflexes
Small text classifiers that label a turn in ~90ms — jailbreaks, NSFW, stuck-in-a-loop, user frustration. Eleven ship ready to use; pass the name asmodel.
GET /v1/reflex/traces.
Merge edits with Fast Apply
Your agent writes a lazy edit snippet — changed lines plus// ... existing code ... markers — and Fast Apply merges it into the file. 10,500 tok/s, 98% accuracy.
Search a codebase with WarpGrep
A separate LLM searches in its own context window — 8 parallel tool calls per turn, file/line spans back in ~3.8 steps — so grep dumps never touch your agent’s context.TypeScript
Compress context with Compact
Shrinks chat history 50-70% at 33,000 tok/s. Every surviving line is byte-for-byte identical to the input;query tells it what the next call needs.
Products
| Product | What it does | Speed | Key metric |
|---|---|---|---|
| Open Source Models | Runs open-weight models (GLM-5.2, Qwen, MiniMax, DeepSeek) behind one endpoint | 90-200 tok/s | up to 1M context |
| Fast Apply | Merges edit snippets into files | 10,500 tok/s | 98% accuracy |
| WarpGrep | Searches code in an isolated context window | ~3.8 steps | #1 SWE-Bench Pro |
| Compact | Removes irrelevant lines from chat history | 33,000 tok/s | 50-70% reduction, verbatim |
| Router | Routes prompts to the right model tier | ~50ms | $0.005/request |
| Reflexes | Classifies text for guardrails and routing | ~90ms | $0.001/event |
Open Source Models: how it works
Open Source Models: how it works
Six open-weight models run on Morph’s custom kernels: Qwen 3.6 27B at 131k context up to GLM-5.2 744B at 1M context. Same OpenAI-compatible endpoint, same API key as Fast Apply, WarpGrep, and Compact — change the
model string, nothing else.Automatic prefix caching is on for every model, no configuration required. All models support tool calls, JSON mode, and reasoning.Speed comes from training a speculator on the model’s own coding output (3.07x vs. 1.93x for a generic draft) and FP4 kernels tuned per-GPU, not a stock deploy. How we optimize for codegen →Full guide →Fast Apply: how it works
Fast Apply: how it works
Your agent describes a change as a lazy edit snippet (just the changed lines, with
// ... existing code ... markers). Fast Apply merges that snippet into the original file and returns the result.98% accuracy. Sub-second latency on typical files. This is the same approach Cursor uses.Unlike str_replace, the agent never re-reads the file or reproduces source code verbatim.Edit format is one of the highest-leverage variables in agent performance. Can Boluk’s 15-LLM benchmark found Grok Code jumped from 6.7% to 68.3% just by changing how edits were expressed, no retraining.Full guide →WarpGrep: how it works
WarpGrep: how it works
WarpGrep is a separate LLM that searches your codebase in its own context window. It takes a natural language query, issues 8 parallel tool calls per turn, and returns file/line-range spans in ~3.8 steps (under 6 seconds on most repos).The key detail: it runs in isolation. Your main agent’s context stays clean. No 200-file grep dumps polluting the conversation.Paired with Opus, Codex, or MiniMax, WarpGrep reaches #1 on SWE-Bench Pro, 15.6% cheaper and 28% faster than single-model approaches.Full guide →
Compact: how it works
Compact: how it works
Shrinks chat history and code context before sending it to your LLM. 100K tokens compress in under 2 seconds. 50-70% reduction. Every surviving line is byte-for-byte identical to the original.The optional
query parameter makes compression much better. It tells the model what the user is about to ask, so query="auth middleware" keeps auth code and drops DB setup.1M token context window. You can compress entire repositories in a single call.Full guide →Router: how it works
Router: how it works
Not every prompt needs a frontier model. The Router classifies a prompt’s difficulty, ambiguity, and domain in ~50ms and tells you which model to call. Trained on millions of coding prompts.Send the prompt, get back a recommended model, then make your real call. $0.005/request, up to 65,536 tokens of input.Full guide →
Reflexes: how it works
Reflexes: how it works
A Reflex is a small text classifier that returns a label in ~90ms, with no model to train or host. Eleven ship ready to use: jailbreak and guardrail (harassment/NSFW) detectors, leaked-thinking and stuck-in-a-loop detectors, user-frustrated and user-joy, plus difficulty and domain labels for routing.POST text to
/v1/reflex/predict and get a score per class back. $0.001/event, or train your own from labeled examples.Full guide →Get running in 30 seconds
One command installs the MCP server and addsedit_file + codebase_search to your editor. It auto-detects Claude Code, Cursor, Codex, and VS Code, then configures them all.
Terminal
Full MCP setup guide
Per-client configuration, CLAUDE.md prompts, and troubleshooting
Common gotchas
My agent rewrites the whole file instead of using edit snippets
My agent rewrites the whole file instead of using edit snippets
Fast Apply only helps if your agent outputs partial edits. You need to update your agent’s system prompt to use
// ... existing code ... markers. Without this, your agent generates full-file rewrites and there’s nothing for Fast Apply to merge. See the prompt templates.WarpGrep results seem incomplete
WarpGrep results seem incomplete
WarpGrep needs ripgrep installed locally for codebase search. If ripgrep isn’t on PATH, searches will fail silently. GitHub search runs on the cloud and doesn’t need ripgrep.
Compact is dropping lines I need
Compact is dropping lines I need
Use the
query parameter. Without it, Compact makes generic compression decisions. With a specific query like "database connection pooling", it keeps the relevant lines and drops the rest.I'm using Python, not TypeScript
I'm using Python, not TypeScript
The Morph API is OpenAI-compatible. Use the OpenAI Python SDK, point it at
https://api.morphllm.com/v1, and pass your Morph API key. See the quickstart for Python examples. WarpGrep has a dedicated Python guide.If you’re coming from…
- Claude Code / Codex
- Cursor
- Aider / Continue
- Building your own agent
- AI app builders
Install the MCP server.
edit_file and codebase_search appear as tools automatically. No code changes. MCP quickstart →Next steps
Open Source Models
GLM-5.2, Qwen, MiniMax, DeepSeek — context windows and pricing
Fast Apply Quickstart
Prompt templates, code examples, verification
WarpGrep Guide
Codebase search, GitHub search, streaming
Compact Guide
Query-conditioned compression, keepContext tags
Reflexes Guide
Guardrail classifiers — jailbreak, NSFW, loops, frustration
MCP Integration
Claude Code, Cursor, Codex, VS Code
SDK Reference
Full TypeScript SDK documentation
API Playground
Test with live examples
Enterprise
Dedicated instances, self-hosted deployments, zero data retention. 99.9% uptime SLA, SOC2, SSO.Talk to Sales
Custom deployments and volume pricing