Skip to main content
POST
Create a chat completion

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

Use morph-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

See Direct API Access for the full protocol details including tool execution and multi-turn flow.

Multi-Turn Conversation

WarpGrep uses built-in tool calling (up to 6 turns). The agent will:
  1. Turn 1: Analyze your search query and call tools (grep_search, list_directory, glob) to explore
  2. Turns 2-5: Refine search based on results, read specific files
  3. Final turn: Call finish with code locations
You execute tool calls locally and return results as {role: "tool", tool_call_id: "...", content: "..."} messages.

Request Parameters

Tools are built into the model — you do not need to pass a tools parameter. The model will return tool_calls automatically.

Response Format

The agent responds with structured tool_calls:
After you execute tools and return results, the agent continues until it calls finish.
On tool-call turns the assistant 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 ranges
  • list_directory: Explore directory structure
  • glob: 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.
See the Direct API Guide for complete tool specifications.
Implement your tools to tolerate loose argument types. The model may send limit or case_sensitive as strings ("50", "false"), and grep_search may emit undocumented arguments such as output_lines (an alias for limit) or output_context_lines. Coerce known keys and ignore unrecognized ones rather than erroring. See the Direct API Guide for the full schema and robustness rules.

SDK Integration

For easier integration, use the WarpGrep SDK components:

Error Codes

Direct API Guide

Build your own WarpGrep harness

Python Implementation

Complete Python guide with examples

Authorizations

Authorization
string
header
required

Morph API key, passed as Authorization: Bearer sk-.... Create keys at https://www.morphllm.com/dashboard/api-keys.

Body

application/json

Chat completion request for Apply or Warp Grep (OpenAI-compatible)

Either a Morph Apply request or a Warp Grep request, discriminated by model.

model
enum<string>
default:morph-v3-fast
required

ID of the Apply model to use, or auto to let the router choose

Available options:
morph-v3-fast,
morph-v3-large,
auto
Example:

"morph-v3-fast"

messages
object[]
required

Array containing a single user message with structured content using instruction-guided format

Example:
stream
boolean
default:false

Enable streaming response. When true the response is a text/event-stream of OpenAI-style chat.completion.chunk deltas terminated by data: [DONE].

Example:

false

max_tokens
integer

Maximum number of tokens the Apply model may generate

Example:

150

temperature
number
default:0

Sampling temperature for the Apply request (0.0 for deterministic output)

Example:

0

Response

Chat completion response

Completion returned by a Morph chat model.

id
string
required

Unique identifier for the completion

Example:

"chatcmpl-123"

object
string
required

Always chat.completion

Example:

"chat.completion"

created
integer
required

Unix timestamp of when the completion was created

Example:

1677652288

choices
object[]
required

List of completion choices

Example:
usage
object
required

Usage statistics for the completion request

Example: