---
title: "Agent Query"
method: POST
path: "/agent"
---

# Agent Query

`POST /agent`

Execute an agent-style query using the :class:`MorphikAgent`.

Args:
    request: The query payload containing the natural language question and optional chat_id.
    auth: Authentication context used to enforce limits and access control.
    redis: Redis connection for chat history storage.

Returns:
    A dictionary with the agent's full response.

## Headers

- `authorization` string

## Request body

- AgentQueryRequest — Request model for agent queries
  - `query` string, required — Natural language query for the Morphik agent
  - `chat_id` string, nullable — Optional chat session ID for persisting conversation history
  - `display_mode` 'formatted' | 'raw' — Display mode for images: 'formatted' (default) creates bounding boxes with Gemini, 'raw' returns uncropped images

## Response `200`

Successful Response

- object

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/morphik-org/apis/fastapi.md) · [All operations](https://skmtc.dev/morphik-org/apis/fastapi/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/morphik-org/fastapi/revisions/9ade02dd7b1d/schema)
