> ## Documentation Index
> Fetch the complete documentation index at: https://www.latitude.sh/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get inference usage for a project

> Returns the project's inference requests, tokens and estimated cost for the window, per model and as a time series. The estimate uses current model prices.




## OpenAPI

````yaml https://spec.speakeasy.com/latitude/latitude/latitude-sh-api-with-code-samples get /inference/usage
openapi: 3.0.1
info:
  title: Latitude.sh API
  version: '2023-06-01'
  description: >-
    The Latitude.sh API is a RESTful API to manage your Latitude.sh account. It
    allows you to perform the same actions as the Latitude.sh dashboard.
servers:
  - url: https://api.latitude.sh
    variables:
      latitude_api_key:
        default: <insert your api key here>
  - url: http://api.latitude.sh
    variables:
      latitude_api_key:
        default: <insert your api key here>
security: []
tags:
  - name: API keys
  - name: Baselines (Preview)
    description: >-
      Preview. Available to teams with the `baselines_api` feature flag. The
      shape of these endpoints may change before general availability.
  - name: Billing
  - name: Elastic Ips
  - name: Events
  - name: Firewalls
  - name: Inference
  - name: IP Addresses
  - name: Managed Databases
    description: Managed database instances (PostgreSQL, ClickHouse)
  - name: Kubernetes Clusters
  - name: LKS
  - name: Marketplace apps
  - name: Operating Systems
  - name: Plans
  - name: Sandboxes (Preview)
    description: >-
      Preview. Available to teams with the `sandboxes_api` feature flag. The
      shape of these endpoints may change before general availability.
  - name: Public Networks
  - name: Private Networks
  - name: Projects
  - name: Regions
  - name: Roles
  - name: SSH Keys
  - name: Servers
  - name: Block Storage
  - name: Filesystem Storage
  - name: Object Storage
  - name: Tags
  - name: Teams
  - name: Team members
  - name: Traffic
  - name: User data
  - name: User profile
  - name: VPN Sessions
  - name: Virtual machines
  - name: Virtual machine backups
  - name: Virtual machine restores
paths:
  /inference/usage:
    get:
      tags:
        - Inference
      summary: Get inference usage for a project
      description: >
        Returns the project's inference requests, tokens and estimated cost for
        the window, per model and as a time series. The estimate uses current
        model prices.
      operationId: get-inference-usage
      parameters:
        - name: project_id
          in: query
          required: true
          description: Project ID or Slug
          examples:
            Success:
              value: proj_AoW6vRnwkvLn0
          schema:
            type: string
        - name: from
          in: query
          required: true
          description: Start of the window (inclusive), truncated to whole seconds
          examples:
            Success:
              value: '2026-10-01T00:00:00Z'
          schema:
            type: string
            format: date-time
        - name: to
          in: query
          required: true
          description: >-
            End of the window (exclusive), truncated to whole seconds; at most
            31 days after from
          examples:
            Success:
              value: '2026-10-02T00:00:00Z'
          schema:
            type: string
            format: date-time
        - name: granularity
          in: query
          required: true
          description: Size of each series bucket
          examples:
            Success:
              value: 6h
          schema:
            type: string
            enum:
              - 1h
              - 6h
              - 24h
      responses:
        '200':
          description: Success
          content:
            application/vnd.api+json:
              examples:
                Success:
                  value:
                    total_estimated_cost: '0.0312'
                    total_requests: 412
                    total_tokens: 186240
                    by_model:
                      - model: qwen3-30b-a3b-fp8
                        requests: 412
                        input_tokens: 142080
                        output_tokens: 44160
                        estimated_cost: '0.0312'
                    series:
                      - timestamp: '2026-10-01T00:00:00Z'
                        models:
                          qwen3-30b-a3b-fp8:
                            requests: 250
                            estimated_cost: '0.0189'
                      - timestamp: '2026-10-01T06:00:00Z'
                        models:
                          qwen3-30b-a3b-fp8:
                            requests: 162
                            estimated_cost: '0.0123'
              schema:
                $ref: '#/components/schemas/inference_usage'
        '403':
          description: >-
            Forbidden — AI Inference is not enabled for the team
            (`FEATURE_NOT_ENABLED`)
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/error_object'
        '404':
          description: Not Found — the project doesn't exist or belongs to another team
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/error_object'
        '422':
          description: >-
            Unprocessable Entity — a parameter is missing, `granularity` is not
            `1h`, `6h`, or `24h`, or the window is shorter than one second or
            longer than 31 days
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/error_object'
        '503':
          description: >-
            Service Unavailable — inference usage is temporarily unavailable
            (`UPSTREAM_SERVICE_ERROR`)
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/error_object'
      security:
        - Bearer: []
      x-codeSamples:
        - lang: python
          label: Python (SDK)
          source: |-
            import latitudesh_python_sdk
            from latitudesh_python_sdk import Latitudesh
            from latitudesh_python_sdk.utils import parse_datetime
            import os


            with Latitudesh(
                bearer=os.getenv("LATITUDESH_BEARER", ""),
            ) as latitudesh:

                res = latitudesh.inference.get_inference_usage(project_id="proj_AoW6vRnwkvLn0", from_=parse_datetime("2026-10-01T00:00:00Z"), to=parse_datetime("2026-10-02T00:00:00Z"), granularity=latitudesh_python_sdk.Granularity.SIXH)

                # Handle response
                print(res)
components:
  schemas:
    inference_usage:
      type: object
      properties:
        total_estimated_cost:
          type: string
          example: '0.88'
          description: Estimated USD across priced models
        total_requests:
          type: integer
        total_tokens:
          type: integer
        by_model:
          type: array
          items:
            type: object
            properties:
              model:
                type: string
                example: qwen3-30b-a3b-fp8
              requests:
                type: integer
              input_tokens:
                type: integer
              output_tokens:
                type: integer
              estimated_cost:
                type: string
                example: '0.000599'
                nullable: true
                description: >-
                  Estimated USD at current model prices; null when the model has
                  no price
        series:
          type: array
          items:
            type: object
            properties:
              timestamp:
                type: string
                format: date-time
                description: Start of the bucket (UTC)
              models:
                type: object
                description: Usage in the bucket keyed by model ID
                additionalProperties:
                  type: object
                  properties:
                    requests:
                      type: integer
                    estimated_cost:
                      type: string
                      example: '0.000599'
                      nullable: true
                      description: >-
                        Estimated USD at current model prices; null when the
                        model has no price
    error_object:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
                nullable: true
              status:
                type: string
              title:
                type: string
              detail:
                type: string
              source:
                type: object
                properties:
                  pointer:
                    type: string
                  parameter:
                    type: string
              meta:
                type: object
  securitySchemes:
    Bearer:
      type: apiKey
      name: Authorization
      in: header

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.