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

# Get Model usage by model name



## OpenAPI

````yaml https://app.stainlessapi.com/api/spec/documented/sgp/openapi.yml get /v4/models/{model_name}/usage-statistics
openapi: 3.1.0
info:
  title: EGP API V4
  description: >-
    This is the parent API for all EGP APIs. If you are looking for the EGP API,
    please go to https://api.egp.scale.com/docs.
  contact:
    name: Scale Generative AI Platform
    url: https://scale.com/genai-platform
  version: 0.1.0
servers:
  - url: https://api.egp.scale.com
security: []
tags:
  - name: Models
    description: Model API.
paths:
  /v4/models/{model_name}/usage-statistics:
    get:
      tags:
        - Models
      summary: Get Model usage by model name
      operationId: GET-V4-/v3/models/{model_name}/usage-statistics
      parameters:
        - name: model_name
          in: path
          required: true
          schema:
            title: Model Name
            type: string
        - name: start_date
          in: query
          required: true
          schema:
            anyOf:
              - type: string
                format: date-time
              - type: 'null'
            title: Start Date
        - name: end_date
          in: query
          required: true
          schema:
            anyOf:
              - type: string
                format: date-time
              - type: 'null'
            title: End Date
        - name: chunks
          in: query
          required: true
          schema:
            anyOf:
              - type: integer
              - type: 'null'
            title: Chunks
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ModelUsageResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from datetime import datetime
            from scale_gp import SGPClient

            client = SGPClient(
                api_key=os.environ.get("SGP_API_KEY"),  # This is the default and can be omitted
            )
            model_usage = client.models.usage_statistics.retrieve(
                model_name="model_name",
                chunks=0,
                end_date=datetime.fromisoformat("2019-12-27T18:11:19.117"),
                start_date=datetime.fromisoformat("2019-12-27T18:11:19.117"),
            )
            print(model_usage.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/stainless-sdks/sgp-go\"\n\t\"github.com/stainless-sdks/sgp-go/option\"\n)\n\nfunc main() {\n\tclient := sgp.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tmodelUsage, err := client.Models.UsageStatistics.Get(\n\t\tcontext.TODO(),\n\t\t\"model_name\",\n\t\tsgp.ModelUsageStatisticGetParams{\n\t\t\tChunks:    sgp.F(int64(0)),\n\t\t\tEndDate:   sgp.F(time.Now()),\n\t\t\tStartDate: sgp.F(time.Now()),\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", modelUsage.Data)\n}\n"
components:
  schemas:
    ModelUsageResponse:
      properties:
        data:
          items:
            $ref: '#/components/schemas/DataPoint'
          type: array
          title: Data
          description: The list of data points for the given period
        start_date:
          type: string
          format: date-time
          title: Start Date
          description: >-
            The start date of the data points. Equal to the first date in the
            data list
        end_date:
          type: string
          format: date-time
          title: End Date
          description: >-
            The end date of the data points. Equal to the last date in the data
            list
      type: object
      required:
        - data
        - start_date
        - end_date
      title: ModelUsageResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    DataPoint:
      properties:
        date:
          type: string
          format: date-time
          title: Date
          description: The start date of the data point
        prompt_tokens:
          type: integer
          title: Prompt Tokens
          description: The number of prompt tokens used
        response_tokens:
          type: integer
          title: Response Tokens
          description: The number of response tokens used
        summary_tokens:
          type: integer
          title: Summary Tokens
          description: The number of all the tokens used
      type: object
      required:
        - date
        - prompt_tokens
        - response_tokens
        - summary_tokens
      title: DataPoint
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
          additionalProperties: true
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````