WarpGrep API
Agentic code search subagent that explores repositories in ~6 seconds
Overview
WarpGrep is a code search agent that uses a multi-turn conversation to explore repositories. The model has its tools (grep_search, read, list_directory, glob, finish) built in — you do not need to pass a tools array in your requests.
Model
Usemorph-warp-grep-v2.1 as the model identifier.
Message Format
WarpGrep uses a structured format in the initial user message with flat absolute paths:Format Components
<repo_structure>: Flat list of absolute paths — repo root first, then all files/directories to depth 2. No indentation, no tree characters, no trailing/on directories.<search_string>: Natural language description of what code to find
Example Request
Multi-Turn Conversation
WarpGrep uses built-in tool calling (up to 6 turns). The agent will:- Turn 1: Analyze your search query and call tools (
grep_search,list_directory,glob) to explore - Turns 2-5: Refine search based on results, read specific files
- Final turn: Call
finishwith code locations
{role: "tool", tool_call_id: "...", content: "..."} messages.
Request Parameters
tools parameter. The model will return tool_calls automatically.Response Format
The agent responds with structuredtool_calls:
finish.
content is null. Read only the tool_calls array.Available Tools
WarpGrep uses five tools:grep_search: Search for regex patterns across files. Case-insensitive by default.read: Read file contents with optional line rangeslist_directory: Explore directory structureglob: Find files by name/extension pattern (sorted by mtime)finish: Submit final answer with code locations. Paths are absolute, matching the paths from the repo structure.
SDK Integration
For easier integration, use the WarpGrep SDK components:- TypeScript Tool: Drop-in tool for AI SDKs
- Python Guide: Complete Python implementation
Error Codes
Direct API Guide
Python Implementation
Authorizations
Morph API key, passed as Authorization: Bearer sk-.... Create keys at https://www.morphllm.com/dashboard/api-keys.
Body
Chat completion request for Apply or Warp Grep (OpenAI-compatible)
- Morph Apply
- Warp Grep
Either a Morph Apply request or a Warp Grep request, discriminated by model.
ID of the Apply model to use, or auto to let the router choose
morph-v3-fast, morph-v3-large, auto "morph-v3-fast"
Array containing a single user message with structured content using instruction-guided format
Enable streaming response. When true the response is a text/event-stream of OpenAI-style chat.completion.chunk deltas terminated by data: [DONE].
false
Maximum number of tokens the Apply model may generate
150
Sampling temperature for the Apply request (0.0 for deterministic output)
0
Response
Chat completion response
Completion returned by a Morph chat model.
Unique identifier for the completion
"chatcmpl-123"
Always chat.completion
"chat.completion"
Unix timestamp of when the completion was created
1677652288
List of completion choices
Usage statistics for the completion request