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

# Run usage

> One run's tokens, spend and spend ceiling, with the attempts that produced them. Requires `usage_read`.

Accepts `run_` followed by 32 hex characters or by a hyphenated UUID, in either case, and returns the hyphenated form.



## OpenAPI

````yaml /api-reference/openapi.json get /v1/usage/runs/{run_id}
openapi: 3.1.0
info:
  title: OpenType API
  version: 0.1.0
  license:
    name: Apache-2.0
  description: >-
    The OpenType HTTP API: decision runs on Neon 1.1, API keys, usage, quota and
    billing. Every `/v1` route takes `Authorization: Bearer <credential>`, where
    the credential is an API key (`otsk_` followed by 64 hex characters) or a
    console session token. Amounts are integers in micro-USD (1,000,000 = 1 US
    dollar). Errors share one envelope, `{"error": {"code", "message",
    "request_id"}}`. Stripe is named only where it hosts checkout, the billing
    portal and receipts.
servers:
  - url: https://api.opentype.dev
    description: Production
  - url: https://api.opentype.dev
    description: Production
security:
  - bearer: []
  - bearer: []
tags:
  - name: runs
    description: Create, list, retrieve and stream runs.
  - name: keys
    description: Create, list, rotate and revoke API keys.
  - name: usage
    description: Usage rollups, the daily series, the ledger and quota.
  - name: billing
    description: Credit balance, checkout, the billing portal and auto-recharge.
  - name: health
    description: Public liveness and readiness checks.
  - name: router
    description: >-
      Model Router: classify a task with Neon 1.1 and pick a model from the
      benchmark catalog.
paths:
  /v1/usage/runs/{run_id}:
    get:
      tags:
        - usage
      summary: Run usage
      description: >-
        One run's tokens, spend and spend ceiling, with the attempts that
        produced them. Requires `usage_read`.


        Accepts `run_` followed by 32 hex characters or by a hyphenated UUID, in
        either case, and returns the hyphenated form.
      operationId: run_usage
      parameters:
        - name: run_id
          in: path
          description: '`run_` followed by 32 hex characters or by a hyphenated UUID.'
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Usage for the run.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunUsageResponse'
        '400':
          description: >-
            `invalid_parameter`: the id does not start with `run_`, or does not
            carry a UUID.
        '401':
          description: >-
            `missing_credentials` (no bearer credential) or `invalid_credential`
            (malformed, unknown or revoked).
        '403':
          description: >-
            `scope_denied`: the credential lacks `usage_read`. A session without
            an organization gets `no_active_organization`.
        '404':
          description: '`run_not_found`: no run with this id in your organization.'
        '500':
          description: '`internal_error`: an unexpected failure. Report the `request_id`.'
        '503':
          description: >-
            `database_not_configured` or `database_unavailable`: accounting
            storage is unavailable. Also `auth_not_configured` or
            `trust_keys_unavailable` when credentials cannot be verified.
      security:
        - bearer: []
        - bearer: []
components:
  schemas:
    RunUsageResponse:
      type: object
      description: '`GET /v1/usage/runs/{run_id}`.'
      required:
        - run_id
        - organization_id
        - state
        - created_at
        - tokens
        - spend
        - ceiling_micros
        - attempts
      properties:
        run_id:
          type: string
        organization_id:
          type: string
        state:
          type: string
        created_at:
          type: string
        tokens:
          $ref: '#/components/schemas/TokenTotalsBody'
        spend:
          $ref: '#/components/schemas/SpendTotalsBody'
        ceiling_micros:
          type: integer
          format: int64
          minimum: 0
        attempts:
          type: array
          items:
            $ref: '#/components/schemas/LedgerEntryBody'
    TokenTotalsBody:
      type: object
      required:
        - input_tokens
        - output_tokens
        - total_tokens
      properties:
        input_tokens:
          type: integer
          format: int64
          minimum: 0
        output_tokens:
          type: integer
          format: int64
          minimum: 0
        total_tokens:
          type: integer
          format: int64
          minimum: 0
    SpendTotalsBody:
      type: object
      required:
        - reserved_micros
        - settled_micros
        - unsettled_micros
      properties:
        reserved_micros:
          type: integer
          format: int64
          minimum: 0
        settled_micros:
          type: integer
          format: int64
          minimum: 0
        unsettled_micros:
          type: integer
          format: int64
          description: '`reserved_micros` minus `settled_micros`, floored at 0.'
          minimum: 0
    LedgerEntryBody:
      type: object
      description: One model attempt.
      required:
        - run_id
        - retry_ordinal
        - provider
        - model_id
        - status
        - tokens
        - cost_micros
        - created_at
      properties:
        run_id:
          type: string
        retry_ordinal:
          type: integer
          format: int32
          minimum: 0
        provider:
          type: string
        model_id:
          type: string
        provider_request_id:
          type:
            - string
            - 'null'
        status:
          type: string
        tokens:
          $ref: '#/components/schemas/TokenTotalsBody'
        cost_micros:
          type: integer
          format: int64
          minimum: 0
        created_at:
          type: string
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: An API key (otsk_ + 64 hex) or a console session token.

````