---
title: "Genai Agents Query"
method: POST
path: "/agents/query"
tags: ["Agents"]
---

# Genai Agents Query

`POST /agents/query`

## Request body

- AgentsQueryReq — Request to list agents with aggregated stats for a project.
  - `project_id` string, required
  - `filters` AgentsQueryFilters — Optional filters for querying agents.
    - `agent_name` string, nullable
  - `sort_by` AgentSortBy[], nullable
    - `field` string, required
    - `direction` 'asc' | 'desc'
  - `limit` integer
  - `offset` integer
  - `include_costs` boolean

## Response `200`

Successful Response

- AgentsQueryRes — Response containing aggregated agent stats.
  - `agents` AgentSchema[], required
    - `project_id` string, required
    - `agent_name` string, required
    - `invocation_count` integer, required
    - `span_count` integer, required
    - `total_input_tokens` integer, required
    - `total_output_tokens` integer, required
    - `total_duration_ms` integer, required
    - `error_count` integer, required
    - `first_seen` string, date-time, nullable, required
    - `last_seen` string, date-time, nullable, required
    - `total_cost_usd` number, nullable
  - `total_count` integer

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/wandb/apis/serverless-training.md) · [All operations](https://skmtc.net/wandb/apis/serverless-training/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/wandb/serverless-training/revisions/8d8d96fc0fd3/schema)
