# Get agent statistics

> Get statistics for an AI agent including invocations, tokens, and costs.

`GET https://api.zavu.dev/v1/senders/{senderId}/agent/stats`

Get statistics for an AI agent including invocations, tokens, and costs.

Covers the messaging channels only. Voice calls are not counted here: a call is a multi-turn conversation rather than one inbound message and one reply, so it is recorded as a call, not an execution. An agent that only answers phone calls reports zeros on every field. Use `GET /v1/calls` for voice activity, duration, and cost.

## Parameters

- `senderId` (path, string, required)

## Responses

### 200

Agent statistics.

- `totalInvocations` (integer, required)
- `totalTokensUsed` (integer, required)
- `totalCost` (number, required): Total cost in USD.
- `successCount` (integer, required): Successful executions among the agent's 100 most recent. Executions with status `filtered` (messages the agent never ran on) are not counted here, in `errorCount` or in `avgLatencyMs`.
- `errorCount` (integer, required): Failed executions among the agent's 100 most recent.
- `avgLatencyMs` (number, nullable): Average latency of the agent's 100 most recent executions, `filtered` excluded. Null when there are none.

### 401

Unauthorized.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 404

Agent not found.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

## Example

```bash
curl -X GET "https://api.zavu.dev/v1/senders/sender_abc123/agent/stats" \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY"
```

```typescript
import Zavudev from "@zavudev/sdk";

const zavu = new Zavudev({ apiKey: process.env.ZAVUDEV_API_KEY });

const result = await zavu.senders.agent.stats("sender_abc123");

console.log(result);
```
