Skip to main content

MorphClient

Unified client for all Morph tools.

redactPII

Keeps personal data and secrets on your machine. Fast Apply, WarpGrep, Compact and the routers send a token in place of each sensitive value and put the real value back in what they return.
  • Fast Apply fails closed. If the merged code holds a token that was never sent, the edit returns success: false and nothing is written.
  • WarpGrep runs its tools on your real files. A grep for a token runs as a grep for the value.
  • Prefix caching is unaffected. Tokens are numbered by where a value first appears, so the same input always produces the same request.
  • Not covered: GitHub search and subagents.
The standalone clients (FastApplyClient, WarpGrepClient, CompactClient, the routers) take the same option.

createRedactingFetch

Chat models are called through the openai package or the AI SDK provider, so the client option never sees those requests. Pass createRedactingFetch() as their fetch. It takes the same values as redactPII.
With the AI SDK provider: createMorph({ fetch: createRedactingFetch() }).
  • Streaming works. A token split across chunks is held until the rest arrives.
  • Prefix caching is unaffected, including across the turns of a conversation.
  • Only /chat/completions is understood. A request with a body to any other path throws before anything is sent.
  • A reply cut off by max_tokens in the middle of a token returns that fragment as written.

Namespaces

Standalone Clients (Advanced)

Need custom configuration per tool? Use individual clients:
Use when: You need tool-specific configuration that differs from defaults (custom URLs, different timeouts, etc.).

Fast Apply

morph.fastApply.execute(input, overrides?)

Edit files with AI-powered merge.

Framework Adapters

Types


WarpGrep

morph.warpGrep.execute(input)

Agentic code search. Runs grep and file reads in a separate context window.

Framework Adapters

Types

Requires ripgrep on the machine running the search. Full options — streaming, GitHub search, sandbox execution — are on the WarpGrep pages.

Environment Variables

Get your API key: morphllm.com/dashboard/api-keys

Import Patterns

Framework Adapters

WarpGrep tools come off the client: morph.anthropic.createWarpGrepTool(), morph.openai.createWarpGrepTool(), morph.vercel.createWarpGrepTool().

Error Handling

All tools return results with success: boolean and optional error: string.
Automatic retries: SDK automatically retries failed requests with exponential backoff for transient errors (rate limits, timeouts).

Next Steps

Examples

See real-world usage patterns

Dashboard

Monitor usage and manage API keys