LangDB Analytics API

Usage analytics and cost summaries.

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/langdb-analytics-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no email required.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

langdb-analytics-api-openapi.yml Raw ↑
openapi: 3.0.1
info:
  title: LangDB AI Gateway Analytics API
  description: OpenAI-compatible REST API for the LangDB AI Gateway. A single, project-scoped endpoint routes chat completions, embeddings, and image generation across 250+ models from providers such as OpenAI, Anthropic, Google, Meta, Mistral, and DeepSeek, while adding routing, guardrails, tracing, cost control, and an MCP (Model Context Protocol) gateway. Requests are authenticated with a Bearer API key and scoped to a project either by embedding the project id in the path (`/{project_id}/v1/...`) or by sending an `X-Project-Id` header. Tracing and session headers (`X-Thread-Id`, `X-Run-Id`, `X-Label`) attach observability metadata to each call.
  termsOfService: https://langdb.ai/terms
  contact:
    name: LangDB Support
    url: https://langdb.ai
    email: support@langdb.ai
  version: '1.0'
servers:
- url: https://api.us-east-1.langdb.ai/{project_id}/v1
  description: Project-scoped OpenAI-compatible base (US East 1).
  variables:
    project_id:
      default: your-langdb-project-id
      description: LangDB project id. May instead be supplied via the X-Project-Id header.
- url: https://api.us-east-1.langdb.ai
  description: Root base URL for analytics, usage, and thread management endpoints (US East 1).
security:
- bearerAuth: []
tags:
- name: Analytics
  description: Usage analytics and cost summaries.
paths:
  /analytics:
    post:
      operationId: fetchAnalytics
      tags:
      - Analytics
      summary: Fetch analytics data
      description: Returns time-series analytics for the project, filterable by a preset interval such as last_day, last_week, or last_month.
      parameters:
      - $ref: '#/components/parameters/ProjectIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnalyticsRequest'
      responses:
        '200':
          description: Analytics rows for the requested window.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyticsResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /analytics/summary:
    post:
      operationId: fetchAnalyticsSummary
      tags:
      - Analytics
      summary: Fetch analytics summary
      description: Returns an aggregated analytics summary (totals for requests, tokens, and cost) for the requested window.
      parameters:
      - $ref: '#/components/parameters/ProjectIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnalyticsRequest'
      responses:
        '200':
          description: Aggregated analytics summary.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyticsSummary'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /usage/total:
    post:
      operationId: getTotalUsage
      tags:
      - Analytics
      summary: Get total usage
      description: Returns total usage (cost, input tokens, output tokens) for the project over the requested window.
      parameters:
      - $ref: '#/components/parameters/ProjectIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnalyticsRequest'
      responses:
        '200':
          description: Total usage figures.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageTotal'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /usage/models:
    post:
      operationId: getUsageByModel
      tags:
      - Analytics
      summary: Get usage by model
      description: Returns usage broken down per model for the project over the requested window.
      parameters:
      - $ref: '#/components/parameters/ProjectIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnalyticsRequest'
      responses:
        '200':
          description: Per-model usage figures.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageByModel'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    AnalyticsRequest:
      type: object
      properties:
        interval:
          type: string
          description: Preset reporting window.
          enum:
          - last_day
          - last_week
          - last_month
        start_time:
          type: string
          format: date-time
        end_time:
          type: string
          format: date-time
        group_by:
          type: array
          items:
            type: string
    UsageTotal:
      type: object
      properties:
        total_cost:
          type: number
        input_tokens:
          type: integer
        output_tokens:
          type: integer
    UsageByModel:
      type: object
      properties:
        models:
          type: array
          items:
            type: object
            properties:
              model:
                type: string
              total_cost:
                type: number
              input_tokens:
                type: integer
              output_tokens:
                type: integer
    AnalyticsSummary:
      type: object
      properties:
        total_requests:
          type: integer
        total_tokens:
          type: integer
        total_cost:
          type: number
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type: string
    AnalyticsResponse:
      type: object
      properties:
        rows:
          type: array
          items:
            type: object
            properties:
              timestamp:
                type: string
                format: date-time
              requests:
                type: integer
              total_tokens:
                type: integer
              cost:
                type: number
  responses:
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  parameters:
    ProjectIdHeader:
      name: X-Project-Id
      in: header
      required: false
      description: LangDB project id. Optional when the project id is embedded in the request path.
      schema:
        type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'LangDB API key (project access token) sent as `Authorization: Bearer <token>`.'