> ## Documentation Index
> Fetch the complete documentation index at: https://docs.morphllm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Run a model, apply edits at 10,500 tok/s, and search code — one OpenAI-compatible API

## One command to move your agent to Kimi K3.1

Move a production agent off Anthropic or OpenAI onto Kimi K3.1 — a 5% traffic trial or a full migration. One command installs the Morph toolkit and the `morph-migrate` skill, and points your own Claude Code at Kimi K3.1:

```bash Terminal theme={null}
MORPH_API_KEY=YOUR_KEY npx -y @morphllm/morph-setup --kimi
```

Then run `/morph-migrate` in your project, or paste this into Cursor, Claude Code, or another agent:

```text Agent prompt theme={null}
Migrate this project's LLM calls to Morph, on Kimi K3.1 (morph-kimik31).

Install the Morph toolkit and follow the morph-migrate skill end-to-end:
npx -y @morphllm/morph-setup --kimi

Use this key:
MORPH_API_KEY=YOUR_KEY

Offer me a 5% production trial or a full migration.
```

The agent finds your LLM call sites, wires a 5% canary (or a full switch) so you can compare before you commit. Reversible with `morph-setup --restore`.

***

## Open Source Models

Open-weight models — Kimi K3.1, GLM-5.3, GLM-5.3-Flash, DeepSeek V4.1 Flash — on the same OpenAI-compatible API. Call one with the OpenAI package.

**1. Call a model**

Point the OpenAI SDK at Morph and pick a model.

> [tab] TypeScript
>
> ```typescript theme={null}
> import OpenAI from "openai";
>
> const client = new OpenAI({
>   apiKey: process.env.MORPH_API_KEY,
>   baseURL: "https://api.morphllm.com/v1",
> });
>
> const response = await client.chat.completions.create({
>   model: "morph-kimik31",
>   messages: [{ role: "user", content: "Refactor this Express handler to async/await: ..." }],
> });
>
> console.log(response.choices[0].message.content);
> ```

> [tab] Python
>
> ```python theme={null}
> import os
> from openai import OpenAI
>
> client = OpenAI(
>     api_key=os.environ["MORPH_API_KEY"],
>     base_url="https://api.morphllm.com/v1",
> )
>
> response = client.chat.completions.create(
>     model="morph-kimik31",
>     messages=[{"role": "user", "content": "Refactor this Express handler to async/await: ..."}],
> )
>
> print(response.choices[0].message.content)
> ```

Every model and its context window is on the [Open Source Models page](https://docs.morphllm.com/sdk/components/fast-models).

***

## Fast Apply

Your agent outputs a lazy edit snippet (changed lines + `// ... existing code ...` markers). Morph merges it into the original file and returns the result. 98% accuracy, sub-second latency.

**1. Install**

```bash theme={null}
npm install @morphllm/morphsdk
```

Get your API key from the [dashboard](https://morphllm.com/dashboard/api-keys).

**2. Run it**

Save as `apply.ts` and run:

> [tab] SDK
>
> ```typescript theme={null}
> import { MorphClient } from '@morphllm/morphsdk';
>
> const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
>
> const result = await morph.fastApply.execute({
>   target_filepath: 'src/auth.ts',
>   instructions: 'Add null check before session creation',
>   code_edit: `
> // ... existing code ...
> if (!user) throw new Error("User not found");
> // ... existing code ...
>   `
> });
>
> console.log(result.diff);
> ```

> [tab] Python
>
> ```python theme={null}
> from openai import OpenAI
>
> client = OpenAI(
>     api_key=os.environ["MORPH_API_KEY"],
>     base_url="https://api.morphllm.com/v1",
> )
>
> response = client.chat.completions.create(
>     model="morph-v3-fast",
>     messages=[{
>         "role": "user",
>         "content": f"<instruction>{instructions}</instruction>\n<code>{original_code}</code>\n<update>{code_edit}</update>"
>     }],
> )
>
> merged_code = response.choices[0].message.content
> ```

> [tab] cURL
>
> ```bash theme={null}
> curl -X POST "https://api.morphllm.com/v1/chat/completions" \
>   -H "Authorization: Bearer $MORPH_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "model": "morph-v3-fast",
>     "messages": [{
>       "role": "user",
>       "content": "<instruction>Add error handling</instruction>\n<code>function login(email, password) {\n  const user = db.find(email);\n  const session = createSession(user);\n  return session;\n}</code>\n<update>function login(email, password) {\n  // ... existing code ...\n  if (!user) throw new Error(\"User not found\");\n  // ... existing code ...\n}</update>"
>     }]
>   }'
> ```

> [!WARNING]
>
> The `instructions` parameter must be generated by the model, not hardcoded. It provides context for ambiguous edits. Example: "Adding error handling to the user auth and removing the old auth functions."

**3. Add to your agent**

The SDK has tool factories for every major framework — one line gives your agent an `edit_file` tool:

> [tab] Anthropic
>
> ```typescript theme={null}
> import Anthropic from '@anthropic-ai/sdk';
> import { MorphClient } from '@morphllm/morphsdk';
>
> const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
> const anthropic = new Anthropic();
>
> const response = await anthropic.messages.create({
>   model: "claude-sonnet-4-5-20250929",
>   max_tokens: 12000,
>   tools: [morph.anthropic.createEditFileTool()],
>   messages: [{ role: "user", content: "Add error handling to src/auth.ts" }]
> });
> ```

> [tab] OpenAI
>
> ```typescript theme={null}
> import OpenAI from 'openai';
> import { MorphClient } from '@morphllm/morphsdk';
>
> const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
> const openai = new OpenAI();
>
> const response = await openai.chat.completions.create({
>   model: "gpt-5-high",
>   tools: [morph.openai.createEditFileTool()],
>   messages: [{ role: "user", content: "Add error handling to src/auth.ts" }]
> });
> ```

> [tab] Vercel AI SDK
>
> ```typescript theme={null}
> import { generateText, stepCountIs } from 'ai';
> import { anthropic } from '@ai-sdk/anthropic';
> import { MorphClient } from '@morphllm/morphsdk';
>
> const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });
>
> const result = await generateText({
>   model: anthropic('claude-sonnet-4-5-20250929'),
>   tools: { editFile: morph.vercel.createEditFileTool() },
>   prompt: "Add error handling to src/auth.ts",
>   stopWhen: stepCountIs(5)
> });
> ```

For tool definition schemas, system prompt instructions, and output-parsing mode, see the [Fast Apply product page](https://docs.morphllm.com/sdk/components/fast-apply.md).

***

## WarpGrep

Code search subagent. Searches your codebase in its own context window, finds relevant code in 3.8 steps, returns file/line-range spans. Your agent's context stays clean.

**1. Install**

```bash theme={null}
brew install ripgrep   # or: apt-get install ripgrep / choco install ripgrep
```

Same `@morphllm/morphsdk` from above — WarpGrep needs ripgrep on your PATH.

**2. Run it**

```typescript theme={null}
import { MorphClient } from '@morphllm/morphsdk';

const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });

const result = await morph.warpGrep.execute({
  searchTerm: 'Find authentication middleware',
  repoRoot: '.'
});

if (result.success) {
  for (const ctx of result.contexts) {
    console.log(`${ctx.file}: ${ctx.content}`);
  }
}
```

**3. Add to your agent**

Same factory pattern as Fast Apply — `createWarpGrepTool` for any framework:

```typescript theme={null}
const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });

const response = await anthropic.messages.create({
  model: 'claude-sonnet-4-5-20250929',
  max_tokens: 12000,
  tools: [morph.anthropic.createWarpGrepTool({ repoRoot: '.' })],
  messages: [{ role: 'user', content: 'Find authentication middleware' }]
});
```

`morph.openai.createWarpGrepTool()` and `morph.vercel.createWarpGrepTool()` mirror this. For streaming, GitHub search, sandbox execution, and the raw API protocol, see the [WarpGrep product page](https://docs.morphllm.com/sdk/components/warp-grep/index).

## Next Steps

> [card] [Open Source Models](https://docs.morphllm.com/sdk/components/fast-models)
>
> Kimi K3.1, GLM-5.3, GLM-5.3-Flash, DeepSeek V4.1 Flash — context windows and pricing

> [card] [Fast Apply](https://docs.morphllm.com/sdk/components/fast-apply.md)
>
> Tool schemas, system prompts, and the lazy edit format

> [card] [WarpGrep](https://docs.morphllm.com/sdk/components/warp-grep/index)
>
> Streaming, GitHub search, remote execution

> [card] [morph CLI + skills](https://docs.morphllm.com/cli.md)
>
> One command to add Morph to Claude Code, Cursor, Codex, or OpenCode

> [card] [SDK Reference](https://docs.morphllm.com/sdk/reference.md)
>
> Complete API documentation


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.