---
title: "Fetch analytics data"
method: POST
path: "/analytics"
tags: ["Analytics"]
---

# Fetch analytics data

`POST /analytics`

## Request

- Base URL: `https://api.us-east-1.langdb.ai`
- URL: `https://api.us-east-1.langdb.ai/analytics`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/langdb/apis/ai-gateway-api/docs/analytics/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: Start time in microseconds.
  - `end_time_us` integer: End time in microseconds.

## Response `200`

Successful response

- AnalyticsResponse
  - `timeseries` object[], required: An array of analytics timeseries records.
    - `hour` string, required: The timestamp for the record (e.g. 'YYYY-MM-DD HH:mm:ss').
    - `total_cost` number, double, required: Total cost incurred during this period.
    - `total_requests` integer, required: Total number of requests.
    - `avg_duration` number, double, required: Average duration (in milliseconds) of requests.
    - `duration` number, double, required: Duration (in milliseconds) of requests.
    - `duration_p99` number, double, required: 99th percentile of request durations.
    - `duration_p95` number, double, required: 95th percentile of request durations.
    - `duration_p90` number, double, required: 90th percentile of request durations.
    - `duration_p50` number, double, required: 50th percentile of request durations.
    - `total_duration` number, double, required: Total duration (in milliseconds) of all requests.
    - `total_input_tokens` integer, required: Total number of input tokens used.
    - `total_output_tokens` integer, required: Total number of output tokens generated.
    - `error_rate` number, double, required: Error rate (as a percentage) over the period.
    - `error_request_count` integer, required: Number of error requests.
    - `avg_ttft` number, double, required: Average time to first byte (TTFT) in milliseconds.
    - `ttft` number, double, required: Time to first byte (TTFT) in milliseconds.
    - `ttft_p99` number, double, required: 99th percentile of TTFT.
    - `ttft_p95` number, double, required: 95th percentile of TTFT.
    - `ttft_p90` number, double, required: 90th percentile of TTFT.
    - `ttft_p50` number, double, required: 50th percentile of TTFT.
    - `tps` number, double, required: Transactions per second.
    - `tps_p99` number, double, required: 99th percentile TPS.
    - `tps_p95` number, double, required: 95th percentile TPS.
    - `tps_p90` number, double, required: 90th percentile TPS.
    - `tps_p50` number, double, required: 50th percentile TPS.
    - `tpot` number, double, required: Average transactions per output token (Tpot).
    - `tpot_p99` number, double, required: 99th percentile of Tpot.
    - `tpot_p95` number, double, required: 95th percentile of Tpot.
    - `tpot_p90` number, double, required: 90th percentile of Tpot.
    - `tpot_p50` number, double, required: 50th percentile of Tpot.
    - `tag_tuple` string[], required: A tuple of tags associated with the record.
  - `start_time_us` integer, required: Start time in microseconds since epoch.
  - `end_time_us` integer, required: End time 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)
