---
title: "Get usage by model"
method: POST
path: "/usage/models"
tags: ["Analytics"]
---

# Get usage by model

`POST /usage/models`

## Request

- Base URL: `https://api.us-east-1.langdb.ai`
- URL: `https://api.us-east-1.langdb.ai/usage/models`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/langdb/apis/ai-gateway-api/docs/usage/models/post.ts> (a function with typed inputs; its response is checked against the schema)

## Headers

- `X-Project-Id` string, required

## Request body

- object
  - `start_time_us` integer
  - `end_time_us` integer
  - `min_unit` 'hour' | 'day' | 'month': The granularity of the returned usage data.

## Response `200`

Successful response

- GranularUsageResponse
  - `models` object[], required: Usage statistics for each model at the specified granularity (hourly, daily, or monthly)
    - `hour` string: Timestamp for the record
    - `provider` string
    - `model_name` string
    - `total_input_tokens` integer
    - `total_output_tokens` integer
    - `total_cost` number, float
  - `period_start` integer, required: Start of the usage period in microseconds since epoch
  - `period_end` integer, required: End of the usage period in microseconds since epoch

---

[API](https://skmtc.dev/langdb/apis/ai-gateway-api.md) - [All operations](https://skmtc.dev/langdb/apis/ai-gateway-api/llms.txt) - [OpenAPI document](https://skmtc.dev/langdb/apis/ai-gateway-api/revisions/56b3696d655b?raw)
