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

# Get Factory Workloads

> The team's Model Factory workloads feed (the squeue): leaf
training runs, inference deployments and native Slurm jobs with
owner, state, requested/allocated GPUs, per-source freshness and
— for terminal states (completed/failed/all) — the completion
stamp of the terminal record (`ended_at`), bounded and newest
first.

The selected `team_id` must be a team the token's user is a
member of; data of other teams is never returned. The default
state window is running + queued. Windows that include terminal
states read the terminal records (RFTRun/Job rows; the slurmdbd
accounting read for native Slurm jobs) and are bounded to
`limit` rows (default 50, max 200), newest first; `since` bounds
them further by timestamp.



## OpenAPI

````yaml https://api.primeintellect.ai/openapi.json get /api/v1/factory/workloads
openapi: 3.1.0
info:
  title: PI API
  version: 0.1.0
servers:
  - url: https://api.primeintellect.ai
security: []
paths:
  /api/v1/factory/workloads:
    get:
      tags:
        - factory
      summary: Get Factory Workloads
      description: |-
        The team's Model Factory workloads feed (the squeue): leaf
        training runs, inference deployments and native Slurm jobs with
        owner, state, requested/allocated GPUs, per-source freshness and
        — for terminal states (completed/failed/all) — the completion
        stamp of the terminal record (`ended_at`), bounded and newest
        first.

        The selected `team_id` must be a team the token's user is a
        member of; data of other teams is never returned. The default
        state window is running + queued. Windows that include terminal
        states read the terminal records (RFTRun/Job rows; the slurmdbd
        accounting read for native Slurm jobs) and are bounded to
        `limit` rows (default 50, max 200), newest first; `since` bounds
        them further by timestamp.
      operationId: get_factory_workloads_api_v1_factory_workloads_get
      parameters:
        - name: team_id
          in: query
          required: true
          schema:
            type: string
            description: Team whose Model Factory fleet to read
            title: Team Id
          description: Team whose Model Factory fleet to read
        - name: workload_type
          in: query
          required: false
          schema:
            enum:
              - training
              - inference
              - slurm
            type: string
            description: >-
              Limit rows to one workload type (legacy spelling; the
              frozen-contract `type` wins when both are sent)
            title: Workload Type
          description: >-
            Limit rows to one workload type (legacy spelling; the
            frozen-contract `type` wins when both are sent)
        - name: type
          in: query
          required: false
          schema:
            enum:
              - training
              - inference
              - slurm
            type: string
            description: >-
              Limit rows to one workload type (the frozen-contract spelling of
              the filter)
            title: Type
          description: >-
            Limit rows to one workload type (the frozen-contract spelling of the
            filter)
        - name: state
          in: query
          required: false
          schema:
            enum:
              - running
              - queued
              - completed
              - failed
              - all
            type: string
            description: >-
              Limit rows to one normalized state, or 'all' (every mappable
              state); default is running + queued
            title: State
          description: >-
            Limit rows to one normalized state, or 'all' (every mappable state);
            default is running + queued
        - name: since
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                format: date-time
              - type: 'null'
            description: >-
              ISO-8601 bound: rows whose completion (terminal rows) or creation
              stamp is older are excluded
            title: Since
          description: >-
            ISO-8601 bound: rows whose completion (terminal rows) or creation
            stamp is older are excluded
        - name: limit
          in: query
          required: false
          schema:
            anyOf:
              - type: integer
                maximum: 200
                minimum: 1
              - type: 'null'
            description: >-
              Row bound (1..200); defaults to 50 server-side for state windows
              that include terminal states, unbounded otherwise
            title: Limit
          description: >-
            Row bound (1..200); defaults to 50 server-side for state windows
            that include terminal states, unbounded otherwise
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FactoryWorkloadsResponse'
        '401':
          description: Authorization failed
        '422':
          description: Invalid request data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - HTTPBearer: []
components:
  schemas:
    FactoryWorkloadsResponse:
      properties:
        schema_version:
          type: integer
          enum:
            - 1
          const: 1
          title: Schema Version
          default: 1
        as_of:
          type: string
          format: date-time
          title: As Of
        workloads:
          items:
            $ref: '#/components/schemas/FactoryWorkload'
          type: array
          title: Workloads
        sources:
          items:
            $ref: '#/components/schemas/WorkloadSource'
          type: array
          title: Sources
      additionalProperties: false
      type: object
      required:
        - as_of
        - workloads
        - sources
      title: FactoryWorkloadsResponse
      description: Envelope for the workloads feed (public + internal routes).
    ErrorResponse:
      properties:
        errors:
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type: array
          title: Errors
      type: object
      required:
        - errors
      title: ErrorResponse
    FactoryWorkload:
      properties:
        id:
          type: string
          title: Id
        type:
          type: string
          enum:
            - training
            - inference
            - slurm
          title: Type
        cluster_display_name:
          type: string
          title: Cluster Display Name
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
        state:
          type: string
          enum:
            - queued
            - running
            - stopping
            - completed
            - failed
            - unknown
          title: State
        native_state:
          anyOf:
            - type: string
            - type: 'null'
          title: Native State
        owner:
          $ref: '#/components/schemas/WorkloadOwner'
        requested_gpus:
          anyOf:
            - type: integer
            - type: 'null'
          title: Requested Gpus
        allocated_gpus:
          anyOf:
            - type: integer
            - type: 'null'
          title: Allocated Gpus
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created At
        started_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Started At
        ended_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Ended At
        scheduler_display_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Scheduler Display Name
        source:
          $ref: '#/components/schemas/WorkloadSource'
      additionalProperties: false
      type: object
      required:
        - id
        - type
        - cluster_display_name
        - state
        - owner
        - source
      title: FactoryWorkload
      description: |-
        One leaf workload row (the squeue line).

        - `id` is a stable OPAQUE public id (type prefix + truncated hash
          of internal identity). It never encodes internal DB ids, release
          or namespace names in readable form.
        - `native_state` is a single coarse passthrough token (e.g. RUNNING,
          PENDING, DEPLOYING) — never raw scheduler flag arrays.
        - `requested_gpus` is the desired/configured footprint, NOT proof
          of bound resources; `allocated_gpus` is observed bound evidence
          and is null when that evidence is missing or stale (never 0 to
          look tidy). A queued row legitimately reports allocated 0.
        - `ended_at` (v1.5.1) is the completion stamp of TERMINAL rows
          (state completed/failed), from the terminal record of truth —
          null for active rows and never invented when the source lacks
          it.
        - Array parents are summary rows: they hold no allocation of their
          own and are never double-counted with their children.
    WorkloadSource:
      properties:
        kind:
          type: string
          enum:
            - training
            - inference
            - slurm
          title: Kind
        status:
          type: string
          enum:
            - ok
            - stale
            - error
          title: Status
        observed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Observed At
      additionalProperties: false
      type: object
      required:
        - kind
        - status
      title: WorkloadSource
      description: |-
        Freshness/coverage entry for the evidence behind one row.

        EXACTLY these three keys (same vocabulary as FactorySourceStatus).
        No source id, adapter detail, endpoint or raw error may ever be
        added here.
    ErrorDetail:
      properties:
        param:
          type: string
          title: Param
        details:
          type: string
          title: Details
      type: object
      required:
        - param
        - details
      title: ErrorDetail
    WorkloadOwner:
      properties:
        kind:
          type: string
          enum:
            - prime
            - slurm
            - unknown
          title: Kind
        display_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Display Name
      additionalProperties: false
      type: object
      required:
        - kind
      title: WorkloadOwner
      description: |-
        Who owns one workload — display identity only, never internal.

        `kind="prime"` shows only the linked Prime user's public display
        name (never email, internal user id or any other identity field).
        `kind="slurm"` shows the native Slurm username when resolvable
        (the slurmrestd-reported name or the platform-provisioned roster
        mapping of the wire's numeric uid), OR the numeric uid string when
        the name is unresolvable — e.g. out-of-band Slurm users created
        directly on the cluster: the uid is the native identity of record
        the live wire always carries, matching squeue's own rendering of
        unresolved users. `kind` stays "slurm" in both cases.
        `kind="unknown"` (display_name null) is reserved for jobs with NO
        user identity on the wire. A Slurm deployment owner is NOT assumed
        to own jobs other users submitted. Nulls stay null and are never
        disguised with an empty string or a fallback id/email.
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````

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