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

# Get a request trace



## OpenAPI

````yaml /openapi.json get /requests/{id}
openapi: 3.1.0
info:
  title: NinjaChat API
  version: 1.0.0
  description: >-
    Clean-break NinjaChat v1. Chat and Responses bill actual token usage; images
    and videos use catalog unit pricing.
servers:
  - url: https://www.ninjachat.ai/api/v1
security: []
paths:
  /requests/{id}:
    get:
      summary: Get a request trace
      parameters:
        - schema:
            type: string
          required: true
          name: id
          in: path
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestRecordResponse'
        '400':
          description: Invalid or unsupported request parameter.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Insufficient balance or project spend limit reached.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Gateway error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: javascript
          label: TypeScript SDK
          source: >-
            import { NinjaChat } from "@ninjachat/sdk";


            const client = new NinjaChat({ apiKey:
            process.env.NINJACHAT_API_KEY! });

            const trace = await client.requests.get("request_id");


            console.log(trace);
        - lang: python
          label: Python SDK
          source: |-
            import os
            from ninjachat import NinjaChat

            client = NinjaChat(api_key=os.environ["NINJACHAT_API_KEY"])
            trace = client.requests.get("request_id")

            print(trace)
components:
  schemas:
    RequestRecordResponse:
      type: object
      properties:
        object:
          type: string
          enum:
            - request
        request_id:
          type: string
        timestamp:
          type:
            - string
            - 'null'
        endpoint:
          type:
            - string
            - 'null'
        model_requested:
          type:
            - string
            - 'null'
        model:
          type:
            - string
            - 'null'
        provider:
          type:
            - string
            - 'null'
        tokens:
          type: object
          properties:
            input:
              type:
                - number
                - 'null'
            output:
              type:
                - number
                - 'null'
            reasoning:
              type:
                - number
                - 'null'
            cached:
              type:
                - number
                - 'null'
            cache_write:
              type:
                - number
                - 'null'
          required:
            - input
            - output
            - reasoning
            - cached
            - cache_write
          additionalProperties: false
        cost_cents:
          type:
            - number
            - 'null'
        metered_cost_cents:
          type:
            - number
            - 'null'
        latency_ms:
          type:
            - number
            - 'null'
        ttfb_ms:
          type:
            - number
            - 'null'
        status_code:
          type:
            - integer
            - 'null'
        retries:
          type:
            - integer
            - 'null'
        error_code:
          type:
            - string
            - 'null'
        routing:
          type:
            - object
            - 'null'
          properties:
            requested_models:
              type: array
              items:
                type: string
                minLength: 1
                maxLength: 160
            policy:
              type:
                - object
                - 'null'
              properties:
                strategy:
                  type: string
                  enum:
                    - balanced
                    - cost
                    - latency
                    - quality
                data_policy:
                  type: string
                  enum:
                    - default
                    - no_training
                    - zero_retention
                caching:
                  type: string
                  enum:
                    - auto
                source:
                  type: string
                  enum:
                    - request
                    - project
                    - default
                allow_fallbacks:
                  type: boolean
                require_parameters:
                  type: boolean
                providers:
                  type: object
                  properties:
                    only:
                      type: array
                      items:
                        type: string
                    exclude:
                      type: array
                      items:
                        type: string
                    order:
                      type: array
                      items:
                        type: string
                  additionalProperties: false
                max_cost_usd:
                  type: number
                  exclusiveMinimum: 0
              required:
                - strategy
                - data_policy
                - source
                - allow_fallbacks
                - require_parameters
                - providers
              additionalProperties: false
            ordering:
              type: string
              enum:
                - breaker
                - perf
                - static
            considered:
              type: array
              items:
                type: string
                minLength: 1
                maxLength: 160
            excluded:
              type: array
              items:
                type: object
                properties:
                  model:
                    type: string
                    minLength: 1
                    maxLength: 160
                  stage:
                    type: string
                  reason:
                    type: string
                required:
                  - model
                  - stage
                  - reason
                additionalProperties: false
            attempts:
              type: array
              items:
                type: object
                properties:
                  model:
                    type: string
                    minLength: 1
                    maxLength: 160
                  outcome:
                    type: string
                    enum:
                      - ok
                      - error
                      - timeout
                      - aborted
                  error_code:
                    type:
                      - string
                      - 'null'
                  latency_ms:
                    type: number
                    minimum: 0
                  retry_budget_consumed:
                    type: boolean
                required:
                  - model
                  - outcome
                  - error_code
                  - latency_ms
                  - retry_budget_consumed
                additionalProperties: false
            served_by:
              type:
                - object
                - 'null'
              properties:
                model:
                  type: string
                  minLength: 1
                  maxLength: 160
                provider:
                  type:
                    - string
                    - 'null'
                attempt_index:
                  type: integer
                  minimum: 0
              required:
                - model
                - provider
                - attempt_index
              additionalProperties: false
          required:
            - requested_models
            - policy
            - ordering
            - considered
            - excluded
            - attempts
            - served_by
          additionalProperties: false
      required:
        - object
        - request_id
        - timestamp
        - endpoint
        - model_requested
        - model
        - provider
        - tokens
        - cost_cents
        - metered_cost_cents
        - latency_ms
        - ttfb_ms
        - status_code
        - retries
        - error_code
        - routing
      additionalProperties: false
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type: string
            param:
              type:
                - string
                - 'null'
          required:
            - message
            - type
            - code
          additionalProperties: false
      required:
        - error
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: NinjaChat API key
      description: Use an API key created in the NinjaChat developer console.

````