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

# List Chunks of Artifacts with Pagination

> ### Description
List chunks for a specific artifact. This API supports pagination and reads only from the data store to allow
querying chunks that are failed as well to enumerate all chunks of a specific artifact.



## OpenAPI

````yaml https://app.stainlessapi.com/api/spec/documented/sgp/openapi.yml get /v4/knowledge-bases/{knowledge_base_id}/artifacts/{artifact_id}/chunks
openapi: 3.1.0
info:
  title: EGP API V4
  description: >-
    This is the parent API for all EGP APIs. If you are looking for the EGP API,
    please go to https://api.egp.scale.com/docs.
  contact:
    name: Scale Generative AI Platform
    url: https://scale.com/genai-platform
  version: 0.1.0
servers:
  - url: https://api.egp.scale.com
security: []
tags:
  - name: Models
    description: Model API.
paths:
  /v4/knowledge-bases/{knowledge_base_id}/artifacts/{artifact_id}/chunks:
    get:
      tags:
        - Knowledge Bases
      summary: List Chunks of Artifacts with Pagination
      description: >-
        ### Description

        List chunks for a specific artifact. This API supports pagination and
        reads only from the data store to allow

        querying chunks that are failed as well to enumerate all chunks of a
        specific artifact.
      operationId: >-
        GET-V4-/knowledge-bases/{knowledge_base_id}/artifacts/{artifact_id}/chunks
      parameters:
        - name: knowledge_base_id
          in: path
          required: true
          schema:
            type: string
            title: Knowledge Base Id
        - name: artifact_id
          in: path
          required: true
          schema:
            title: Artifact Id
            type: string
        - name: chunk_status
          in: query
          required: false
          schema:
            anyOf:
              - $ref: >-
                  #/components/schemas/egp_api_backend__server__internal__entities__ChunkUploadStatus
              - type: 'null'
            description: Filter by the status of the chunks
            title: Chunk Status
          description: Filter by the status of the chunks
        - name: page
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            description: >-
              Page number for pagination to be returned by the given endpoint.
              Starts at page 1
            default: 1
            title: Page
          description: >-
            Page number for pagination to be returned by the given endpoint.
            Starts at page 1
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 10000
            minimum: 1
            description: >-
              Maximum number of artifacts to be returned by the given endpoint.
              Defaults to 100 and cannot be greater than 10k.
            default: 100
            title: Limit
          description: >-
            Maximum number of artifacts to be returned by the given endpoint.
            Defaults to 100 and cannot be greater than 10k.
        - name: x-selected-account-id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Account ID Header
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedChunkWithStatus'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from scale_gp import SGPClient

            client = SGPClient(
                api_key=os.environ.get("SGP_API_KEY"),  # This is the default and can be omitted
            )
            page = client.knowledge_bases.artifacts.chunks.list(
                artifact_id="artifact_id",
                knowledge_base_id="knowledge_base_id",
            )
            page = page.items[0]
            print(page.id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/stainless-sdks/sgp-go\"\n\t\"github.com/stainless-sdks/sgp-go/option\"\n)\n\nfunc main() {\n\tclient := sgp.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.KnowledgeBases.Artifacts.Chunks.List(\n\t\tcontext.TODO(),\n\t\t\"knowledge_base_id\",\n\t\t\"artifact_id\",\n\t\tsgp.KnowledgeBaseArtifactChunkListParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n"
components:
  schemas:
    egp_api_backend__server__internal__entities__ChunkUploadStatus:
      type: string
      enum:
        - Pending
        - Completed
        - Failed
      title: ChunkUploadStatus
    PaginatedChunkWithStatus:
      properties:
        items:
          items:
            $ref: '#/components/schemas/ChunkWithStatus'
          type: array
          title: Items
          description: The data returned for the current page.
        total_item_count:
          type: integer
          title: Total Item Count
          description: The total number of items of the query
        current_page:
          type: integer
          title: Current Page
          description: The current page number.
        items_per_page:
          type: integer
          title: Items Per Page
          description: The number of items per page.
      type: object
      required:
        - items
        - total_item_count
        - current_page
        - items_per_page
      title: PaginatedChunkWithStatus
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ChunkWithStatus:
      properties:
        id:
          type: string
          title: Id
          description: The id of the chunk
        text:
          type: string
          title: Text
          description: The text of the chunk as stored in the database
        artifact_id:
          type: string
          title: Artifact Id
          description: The id of the artifact
        chunk_position:
          type: integer
          title: Chunk Position
          description: Chunk position
        metadata:
          title: Metadata
          description: Metadata of the chunk which is stored in OpenSearch
          default: {}
          additionalProperties: true
          type: object
        user_supplied_metadata:
          title: User Supplied Metadata
          description: >-
            Metadata of the chunk which is stored in the database only provided
            via custom chunking.
          default: {}
          additionalProperties: true
          type: object
        status:
          $ref: >-
            #/components/schemas/egp_api_backend__server__internal__entities__ChunkUploadStatus
          description: >-
            Status of the chunk. If Failed or Pending, its possible that the
            chunk does not reflect in OpenSearch
        status_reason:
          title: Status Reason
          description: Status reason of the chunk. May be successful
          type: string
        created_at:
          title: Created At
          description: Date and time of chunk creation
          type: string
          format: date-time
      type: object
      required:
        - id
        - text
        - artifact_id
        - chunk_position
        - status
      title: ChunkWithStatus
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
          additionalProperties: true
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-api-key

````