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

# List data source sessions

> Get aggregated session data for a data source (formerly known as "inference pipeline")



## OpenAPI

````yaml post /inference-pipelines/{inferencePipelineId}/sessions
openapi: 3.0.3
info:
  contact:
    email: support@openlayer.com
    name: Openlayer
    url: https://openlayer.com/
  description: API for interacting with the Openlayer server.
  title: Openlayer API
  version: '1.0'
  x-logo:
    url: https://logo.clearbit.com/openlayer.com
servers:
  - url: https://api.openlayer.com/v1
    description: Our prod backend
security:
  - bearerAuth: []
paths:
  /inference-pipelines/{inferencePipelineId}/sessions:
    post:
      tags:
        - Monitoring
      summary: List sessions
      description: List the sessions in an inference pipeline, with their stats.
      parameters:
        - $ref: '#/components/parameters/inferencePipelineId'
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/perPage'
        - name: sortColumn
          in: query
          description: Name of the column to sort on
          required: false
          schema:
            type: string
        - name: asc
          in: query
          description: Whether or not to sort on the sortColumn in ascending order.
          required: false
          schema:
            type: boolean
            default: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DatasetFilter'
      responses:
        '200':
          description: Response OK.
          content:
            application/json:
              schema:
                type: object
                required:
                  - items
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/SessionAggregation'
                    description: Array of session aggregation data
        '202':
          description: Request accepted, data is being loaded.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
        default:
          $ref: '#/components/responses/UnexpectedError'
      x-codeSamples:
        - lang: python
          source: |
            from openlayer import Openlayer

            client = Openlayer()

            sessions = client.inference_pipelines.retrieve_sessions(
                "c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
                per_page=50,
            )
            print(sessions.items)
        - lang: typescript
          source: >
            import Openlayer from 'openlayer';


            const client = new Openlayer();


            const sessions = await
            client.inferencePipelines.retrieveSessions('c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f',
            { perPage: 50 });


            console.log(sessions.items);
        - lang: go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openlayer-ai/openlayer-go\"\n)\n\nclient := openlayer.NewClient()\nsessions, err := client.InferencePipelines.GetSessions(\n\tcontext.TODO(),\n\t\"c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f\",\n\topenlayer.InferencePipelineGetSessionsParams{\n\t\tPerPage: openlayer.Int(25),\n\t},\n)\nif err != nil {\n\tpanic(err.Error())\n}\nfmt.Printf(\"%+v\\n\", sessions.Items)\n"
        - lang: java
          source: >
            import com.openlayer.api.client.OpenlayerClient;

            import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient;

            import
            com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveSessionsParams;

            import
            com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveSessionsResponse;


            OpenlayerClient client = OpenlayerOkHttpClient.fromEnv();


            InferencePipelineRetrieveSessionsParams params =
            InferencePipelineRetrieveSessionsParams.builder()
                .inferencePipelineId("c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f")
                .perPage(50L)
                .build();
            InferencePipelineRetrieveSessionsResponse sessions =
            client.inferencePipelines().retrieveSessions(params);
        - lang: ruby
          source: >
            require "openlayer"


            openlayer = Openlayer::Client.new(api_key: ENV["OPENLAYER_API_KEY"])


            sessions =
            openlayer.inference_pipelines.retrieve_sessions("c1d2e3f4-a5b6-4c7d-8e9f-0a1b2c3d4e5f",
            per_page: 50)


            puts(sessions)
        - lang: curl
          source: |
            curl --request POST \
              --url https://api.openlayer.com/v1/inference-pipelines/{inferencePipelineId}/sessions \
              --header 'Authorization: Bearer <token>' \
              --header 'Content-Type: application/json' \
              --data '{}'
components:
  parameters:
    inferencePipelineId:
      name: inferencePipelineId
      in: path
      description: The inference pipeline id (a UUID).
      required: true
      schema:
        type: string
        format: uuid
    page:
      name: page
      in: query
      description: The page to return in a paginated query.
      schema:
        type: integer
        minimum: 1
        default: 1
    perPage:
      name: perPage
      in: query
      description: Maximum number of items to return per page.
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 25
  schemas:
    DatasetFilter:
      type: object
      nullable: true
      properties:
        columnFilters:
          type: array
          nullable: true
          maxItems: 5
          items:
            oneOf:
              - title: SetColumnFilter
                type: object
                example:
                  measurement: openlayer_token_set
                  operator: contains_none
                  value:
                    - cat
                required:
                  - measurement
                  - operator
                  - value
                properties:
                  measurement:
                    type: string
                    description: The name of the column.
                  operator:
                    type: string
                    enum:
                      - contains_none
                      - contains_any
                      - contains_all
                      - one_of
                      - none_of
                  value:
                    type: array
                    items:
                      oneOf:
                        - type: string
                        - type: number
              - title: NumericColumnFilter
                type: object
                example:
                  measurement: Age
                  operator: '>='
                  value: 25
                required:
                  - measurement
                  - operator
                  - value
                properties:
                  measurement:
                    type: string
                    description: The name of the column.
                  operator:
                    type: string
                    enum:
                      - '>'
                      - '>='
                      - is
                      - <
                      - <=
                      - '!='
                  value:
                    type: number
                    format: float
                    nullable: true
                    example: 0.93
              - title: StringColumnFilter
                type: object
                example:
                  measurement: Geography
                  operator: is
                  value: Germany
                required:
                  - measurement
                  - operator
                  - value
                properties:
                  measurement:
                    type: string
                    description: The name of the column.
                  operator:
                    type: string
                    enum:
                      - is
                      - '!='
                  value:
                    oneOf:
                      - type: string
                        example: Germany
                      - type: boolean
        searchQueryOr:
          type: array
          items:
            type: string
            maxLength: 300
          nullable: true
        searchQueryAnd:
          type: array
          items:
            type: string
            maxLength: 300
          nullable: true
        notSearchQueryOr:
          type: array
          items:
            type: string
            maxLength: 300
          nullable: true
        notSearchQueryAnd:
          type: array
          items:
            type: string
            maxLength: 300
          nullable: true
        rowIdList:
          type: array
          nullable: true
          items:
            type: integer
        excludeRowIdList:
          type: array
          nullable: true
          items:
            type: integer
    SessionAggregation:
      type: object
      description: >-
        A session in an inference pipeline, with its activity stats: record
        counts, token usage, cost, latency, and its first and last records.
      required:
        - id
        - dateCreated
        - dateOfFirstRecord
        - dateOfLastRecord
        - duration
        - records
        - userIds
        - tokens
        - cost
        - latency
        - firstRecord
        - lastRecord
      properties:
        id:
          type: string
          description: The unique session identifier
          example: session456
        dateCreated:
          type: string
          format: date-time
          description: Latest/most recent timestamp in the session
          example: '2022-01-02T08:00:00Z'
        dateOfFirstRecord:
          type: string
          format: date-time
          description: Timestamp of the first request in the session
          example: '2022-01-02T07:58:20Z'
        dateOfLastRecord:
          type: string
          format: date-time
          description: Timestamp of the last request in the session
          example: '2022-01-02T08:00:00Z'
        duration:
          type: number
          format: float
          description: Duration between first and last request (in milliseconds)
          example: 100576.341
        records:
          type: integer
          description: Total number of records/traces in the session
          example: 15
        userIds:
          type: array
          items:
            type: string
          description: List of unique user IDs that participated in this session
          example:
            - user123
            - user456
        tokens:
          type: number
          format: float
          description: Total token count for the session
          example: 1250
        cost:
          type: number
          format: float
          description: Total cost for the session
          example: 0.025
        latency:
          type: number
          format: float
          description: Total latency for the session (in milliseconds)
          example: 1250.5
        firstRecord:
          type: object
          description: The complete first record in the session
          additionalProperties: true
        lastRecord:
          type: object
          description: The complete last record in the session
          additionalProperties: true
  responses:
    UnexpectedError:
      description: Unexpected error.
      content:
        application/json:
          schema:
            type: object
            required:
              - code
              - error
            properties:
              code:
                type: integer
                format: int32
              error:
                type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >
        Bearer authentication header of the form `Bearer <token>`, where
        `<token>` is your workspace API key. See [Find your API
        key](https://www.openlayer.com/docs/workspace-and-projects/find-your-api-key)
        for more information.

````

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