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

# Get pull request coding agent usage

> Assistant usage for one pull request: sessions, tokens and cost, grouped by contributor and agent, plus per-model totals, over the pull request's whole lifetime rather than a time window. Every row and the totals split cost three ways: the part priced per token, the part a bundled subscription already covers, and the list-price total of both. Per-model totals carry the list price only. Cost is calculated from the tokens the agent reported and LangWatch's model prices, so it estimates spend rather than restating a provider invoice. Requires a personal-project API key; rows appear only for projects the calling user may view, and cost only for those they may price.



## OpenAPI

````yaml GET /api/coding-agent/pull-request-usage
openapi: 3.1.0
info:
  title: LangWatch API
  version: 1.0.0
  description: LangWatch openapi spec
servers:
  - url: https://app.langwatch.ai
security:
  - project_api_key: []
paths:
  /api/coding-agent/pull-request-usage:
    get:
      summary: Get pull request coding agent usage
      description: >-
        Assistant usage for one pull request: sessions, tokens and cost, grouped
        by contributor and agent, plus per-model totals, over the pull request's
        whole lifetime rather than a time window. Every row and the totals split
        cost three ways: the part priced per token, the part a bundled
        subscription already covers, and the list-price total of both. Per-model
        totals carry the list price only. Cost is calculated from the tokens the
        agent reported and LangWatch's model prices, so it estimates spend
        rather than restating a provider invoice. Requires a personal-project
        API key; rows appear only for projects the calling user may view, and
        cost only for those they may price.
      operationId: getApiCoding-agentPull-request-usage
      parameters:
        - name: repository
          in: query
          required: true
          schema:
            type: string
          description: The repository as "owner/name".
        - name: pullRequest
          in: query
          required: true
          schema:
            type: integer
          description: The pull request number.
        - name: host
          in: query
          required: false
          schema:
            type: string
            default: github.com
      responses:
        '200':
          description: The pull request's usage rollup
          content:
            application/json:
              schema:
                type: object
                properties:
                  pullRequest:
                    type: object
                    properties:
                      repositoryHost:
                        type: string
                      repositoryFullName:
                        type: string
                      prNumber:
                        type: number
                      headBranch:
                        type: string
                      htmlUrl:
                        type: string
                      state:
                        type: string
                      isDraft:
                        type: boolean
                      authorLogin:
                        type:
                          - string
                          - 'null'
                      prCreatedAtMs:
                        type: number
                      prClosedAtMs:
                        type:
                          - number
                          - 'null'
                      prMergedAtMs:
                        type:
                          - number
                          - 'null'
                    required:
                      - repositoryHost
                      - repositoryFullName
                      - prNumber
                      - headBranch
                      - htmlUrl
                      - state
                      - isDraft
                      - authorLogin
                      - prCreatedAtMs
                      - prClosedAtMs
                      - prMergedAtMs
                  rows:
                    type: array
                    items:
                      type: object
                      properties:
                        projectId:
                          type: string
                        projectSlug:
                          type: string
                        contributorLabel:
                          type: string
                        contributorIsProject:
                          type: boolean
                        agent:
                          type: string
                        models:
                          type: array
                          items:
                            type: string
                        sessionsCount:
                          type: number
                        inputTokens:
                          type: number
                        outputTokens:
                          type: number
                        cacheReadTokens:
                          type: number
                        cacheCreationTokens:
                          type: number
                        totalTokens:
                          type: number
                        costUsd:
                          type:
                            - number
                            - 'null'
                        billedCostUsd:
                          type:
                            - number
                            - 'null'
                        nonBilledCostUsd:
                          type:
                            - number
                            - 'null'
                      required:
                        - projectId
                        - projectSlug
                        - contributorLabel
                        - contributorIsProject
                        - agent
                        - models
                        - sessionsCount
                        - inputTokens
                        - outputTokens
                        - cacheReadTokens
                        - cacheCreationTokens
                        - totalTokens
                        - costUsd
                        - billedCostUsd
                        - nonBilledCostUsd
                  totals:
                    type: object
                    properties:
                      sessionsCount:
                        type: number
                      inputTokens:
                        type: number
                      outputTokens:
                        type: number
                      cacheReadTokens:
                        type: number
                      cacheCreationTokens:
                        type: number
                      totalTokens:
                        type: number
                      costUsd:
                        type:
                          - number
                          - 'null'
                      billedCostUsd:
                        type:
                          - number
                          - 'null'
                      nonBilledCostUsd:
                        type:
                          - number
                          - 'null'
                    required:
                      - sessionsCount
                      - inputTokens
                      - outputTokens
                      - cacheReadTokens
                      - cacheCreationTokens
                      - totalTokens
                      - costUsd
                      - billedCostUsd
                      - nonBilledCostUsd
                  modelBreakdown:
                    type: array
                    items:
                      type: object
                      properties:
                        model:
                          type: string
                        inputTokens:
                          type: number
                        outputTokens:
                          type: number
                        cacheReadTokens:
                          type: number
                        cacheCreationTokens:
                          type: number
                        totalTokens:
                          type: number
                        costUsd:
                          type:
                            - number
                            - 'null'
                      required:
                        - model
                        - inputTokens
                        - outputTokens
                        - cacheReadTokens
                        - cacheCreationTokens
                        - totalTokens
                        - costUsd
                required:
                  - pullRequest
                  - rows
                  - totals
                  - modelBreakdown
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
                required:
                  - error
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
                required:
                  - error
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
                required:
                  - error
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
                required:
                  - error
components:
  securitySchemes:
    project_api_key:
      type: apiKey
      in: header
      name: X-Auth-Token
      description: >-
        Project API key for sending traces and accessing project-scoped
        resources. Format: sk-lw-... (no underscore). Obtain one by creating a
        project via the Admin API or the LangWatch UI.

````