## GET /v1/agents/{id}/metrics

Read usage and spend windows for an agent.

Required permissions: read:configs.
API key: Supported.
CLI user token: Supported.
Session token: Requires the ellipsis:api scope, and the session's permissions.ellipsis rules must allow the operation.
Higher permission levels include lower levels: read < write < delete.
Grant match patterns can further restrict access to individual resources.

### Response

```text
{
  "buckets": [
    {
      "cost": {
        "charged": int,
        "cpu": int,
        "fee": int,
        "llm": {
          "all": {
            "claude_subscription": int,
            "codex_subscription": int,
            "platform": int,
            "total": int
          },
          "by_model": [
            {
              "claude_subscription": int,
              "codex_subscription": int,
              "model": str,
              "platform": int,
              "total": int
            }
          ]
        },
        "memory": int,
        "total": int
      },
      "date": str,
      "sessions": int,
      "tokens": {
        "all": {
          "cache_creation": int,
          "cache_read": int,
          "input": int,
          "output": int,
          "total": int
        },
        "by_model": [
          {
            "cache_creation": int,
            "cache_read": int,
            "input": int,
            "model": str,
            "output": int,
            "total": int
          }
        ]
      }
    }
  ],
  "interval": str,
  "samples": [
    {
      "cost": {
        "charged": int,
        "cpu": int,
        "fee": int,
        "llm": {
          "all": {
            "claude_subscription": int,
            "codex_subscription": int,
            "platform": int,
            "total": int
          },
          "by_model": [
            {
              "claude_subscription": int,
              "codex_subscription": int,
              "model": str,
              "platform": int,
              "total": int
            }
          ]
        },
        "memory": int,
        "total": int
      },
      "duration_seconds": float,
      "tokens": {
        "all": {
          "cache_creation": int,
          "cache_read": int,
          "input": int,
          "output": int,
          "total": int
        },
        "by_model": [
          {
            "cache_creation": int,
            "cache_read": int,
            "input": int,
            "model": str,
            "output": int,
            "total": int
          }
        ]
      }
    }
  ],
  "spend_windows": [
    {
      "limit": int,
      "platform_max": int,
      "spent": int,
      "window_days": int
    }
  ]
}
```

### Python

```python
import os

from ellipsis import Ellipsis

client = Ellipsis(api_key=os.environ["ELLIPSIS_API_TOKEN"])

result = client.agents.metrics("...", start="...", end="...")
print(result)
```

### TypeScript

```typescript
import { Ellipsis } from '@ellipsis-dev/sdk';

const client = new Ellipsis({
  apiKey: process.env.ELLIPSIS_API_TOKEN!,
});

const result = await client.agents.metrics('...', { start: '...', end: '...' });
console.log(result);
```

### cURL

```bash
curl "https://api.ellipsis.dev/v1/agents/{id}/metrics?start=...&end=..." \
  -H "Authorization: Bearer $ELLIPSIS_API_TOKEN"
```

### Response schema

```json
{
  "properties": {
    "buckets": {
      "items": {
        "properties": {
          "cost": {
            "properties": {
              "charged": {
                "default": 0,
                "type": "integer"
              },
              "cpu": {
                "default": 0,
                "type": "integer"
              },
              "fee": {
                "default": 0,
                "type": "integer"
              },
              "llm": {
                "properties": {
                  "all": {
                    "properties": {
                      "claude_subscription": {
                        "type": "integer"
                      },
                      "codex_subscription": {
                        "type": "integer"
                      },
                      "platform": {
                        "type": "integer"
                      },
                      "total": {
                        "type": "integer"
                      }
                    },
                    "required": [
                      "claude_subscription",
                      "codex_subscription",
                      "platform",
                      "total"
                    ],
                    "type": "object"
                  },
                  "by_model": {
                    "items": {
                      "type": "object"
                    },
                    "type": "array"
                  }
                },
                "required": [
                  "all",
                  "by_model"
                ],
                "type": "object"
              },
              "memory": {
                "default": 0,
                "type": "integer"
              },
              "total": {
                "default": 0,
                "type": "integer"
              }
            },
            "required": [
              "charged",
              "cpu",
              "fee",
              "llm",
              "memory",
              "total"
            ],
            "type": "object"
          },
          "date": {
            "format": "date-time",
            "type": "string"
          },
          "sessions": {
            "type": "integer"
          },
          "tokens": {
            "properties": {
              "all": {
                "properties": {
                  "cache_creation": {
                    "default": 0,
                    "type": "integer"
                  },
                  "cache_read": {
                    "default": 0,
                    "type": "integer"
                  },
                  "input": {
                    "default": 0,
                    "type": "integer"
                  },
                  "output": {
                    "default": 0,
                    "type": "integer"
                  },
                  "total": {
                    "default": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "cache_creation",
                  "cache_read",
                  "input",
                  "output",
                  "total"
                ],
                "type": "object"
              },
              "by_model": {
                "items": {
                  "properties": {
                    "cache_creation": {
                      "type": "integer"
                    },
                    "cache_read": {
                      "type": "integer"
                    },
                    "input": {
                      "type": "integer"
                    },
                    "model": {
                      "type": "string"
                    },
                    "output": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "cache_creation",
                    "cache_read",
                    "input",
                    "model",
                    "output",
                    "total"
                  ],
                  "type": "object"
                },
                "type": "array"
              }
            },
            "required": [
              "all",
              "by_model"
            ],
            "type": "object"
          }
        },
        "required": [
          "date",
          "sessions",
          "cost",
          "tokens"
        ],
        "type": "object"
      },
      "type": "array"
    },
    "interval": {
      "enum": [
        "hour",
        "day",
        "week"
      ],
      "type": "string"
    },
    "samples": {
      "items": {
        "properties": {
          "cost": {
            "properties": {
              "charged": {
                "default": 0,
                "type": "integer"
              },
              "cpu": {
                "default": 0,
                "type": "integer"
              },
              "fee": {
                "default": 0,
                "type": "integer"
              },
              "llm": {
                "properties": {
                  "all": {
                    "properties": {
                      "claude_subscription": {
                        "type": "integer"
                      },
                      "codex_subscription": {
                        "type": "integer"
                      },
                      "platform": {
                        "type": "integer"
                      },
                      "total": {
                        "type": "integer"
                      }
                    },
                    "required": [
                      "claude_subscription",
                      "codex_subscription",
                      "platform",
                      "total"
                    ],
                    "type": "object"
                  },
                  "by_model": {
                    "items": {
                      "type": "object"
                    },
                    "type": "array"
                  }
                },
                "required": [
                  "all",
                  "by_model"
                ],
                "type": "object"
              },
              "memory": {
                "default": 0,
                "type": "integer"
              },
              "total": {
                "default": 0,
                "type": "integer"
              }
            },
            "required": [
              "charged",
              "cpu",
              "fee",
              "llm",
              "memory",
              "total"
            ],
            "type": "object"
          },
          "duration_seconds": {
            "type": "number"
          },
          "tokens": {
            "properties": {
              "all": {
                "properties": {
                  "cache_creation": {
                    "default": 0,
                    "type": "integer"
                  },
                  "cache_read": {
                    "default": 0,
                    "type": "integer"
                  },
                  "input": {
                    "default": 0,
                    "type": "integer"
                  },
                  "output": {
                    "default": 0,
                    "type": "integer"
                  },
                  "total": {
                    "default": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "cache_creation",
                  "cache_read",
                  "input",
                  "output",
                  "total"
                ],
                "type": "object"
              },
              "by_model": {
                "items": {
                  "properties": {
                    "cache_creation": {
                      "type": "integer"
                    },
                    "cache_read": {
                      "type": "integer"
                    },
                    "input": {
                      "type": "integer"
                    },
                    "model": {
                      "type": "string"
                    },
                    "output": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "cache_creation",
                    "cache_read",
                    "input",
                    "model",
                    "output",
                    "total"
                  ],
                  "type": "object"
                },
                "type": "array"
              }
            },
            "required": [
              "all",
              "by_model"
            ],
            "type": "object"
          }
        },
        "required": [
          "duration_seconds",
          "cost",
          "tokens"
        ],
        "type": "object"
      },
      "type": "array"
    },
    "spend_windows": {
      "items": {
        "properties": {
          "limit": {
            "type": "integer"
          },
          "platform_max": {
            "type": "integer"
          },
          "spent": {
            "type": "integer"
          },
          "window_days": {
            "type": "integer"
          }
        },
        "required": [
          "window_days",
          "spent",
          "limit",
          "platform_max"
        ],
        "type": "object"
      },
      "type": "array"
    }
  },
  "required": [
    "samples",
    "spend_windows",
    "interval",
    "buckets"
  ],
  "type": "object"
}
```
