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

# Retrieve batch prediction results

> Streams newline-delimited JSON (NDJSON) result lines for a terminal batch prediction. Read the response body line-by-line and JSON parse each non-empty line. Results are retained for a limited window after batch creation; after cleanup, this endpoint returns `410 Gone`.



## OpenAPI

````yaml get /batch-predictions/{batch_prediction_id}/results
openapi: 3.0.3
info:
  version: 0.1.1
  title: Datagrid API
  description: Datagrid API
servers:
  - url: https://api.datagrid.com/v1
security:
  - BearerAuth: []
paths:
  /batch-predictions/{batch_prediction_id}/results:
    get:
      tags:
        - Batch Predictions
      summary: Retrieve batch prediction results
      description: >-
        Streams newline-delimited JSON (NDJSON) result lines for a terminal
        batch prediction. Read the response body line-by-line and JSON parse
        each non-empty line. Results are retained for a limited window after
        batch creation; after cleanup, this endpoint returns `410 Gone`.
      operationId: BatchPredictions.retrieveBatchPredictionResults
      parameters:
        - name: batch_prediction_id
          in: path
          required: true
          description: The id of the batch prediction whose results should be streamed.
          schema:
            type: string
      responses:
        '200':
          description: Batch prediction result stream
          headers:
            X-Request-Id:
              description: Request identifier for tracing and support.
              schema:
                type: string
          content:
            application/x-ndjson:
              schema:
                $ref: '#/components/schemas/BatchPredictionResultLine'
              example: >
                {"object":"batch_prediction.result","batch_id":"bpred_abc123","custom_id":"drawing_001","status":"succeeded","output":{"project_name":"Alpha
                Tower","sheet_title":"Floor Plan","revision":"R3"},"error":null}

                {"object":"batch_prediction.result","batch_id":"bpred_abc123","custom_id":"drawing_002","status":"errored","output":null,"error":{"type":"https://api.datagrid.com/errors/prediction_failed","title":"Prediction
                Failed","status":422,"detail":"The model returned an invalid
                response."}}
        '401':
          description: Unauthorized. Authentication is required to retrieve result lines.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '404':
          description: Not found. The requested batch prediction does not exist.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '409':
          description: >-
            Conflict. Results are only available once the batch reaches a
            terminal status.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '410':
          description: >-
            Gone. The batch metadata still exists, but retained result lines
            have been deleted.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '429':
          description: Rate limit exceeded. The request has been throttled.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Datagrid from 'datagrid-ai';


            const client = new Datagrid({
              apiKey: process.env['DATAGRID_API_KEY'], // This is the default and can be omitted
            });


            const batchPredictionResultLine = await
            client.batchPredictions.retrieveResults(
              'batch_prediction_id',
            );


            console.log(batchPredictionResultLine.batch_id);
        - lang: Python
          source: |-
            import os
            from datagrid_ai import Datagrid

            client = Datagrid(
                api_key=os.environ.get("DATAGRID_API_KEY"),  # This is the default and can be omitted
            )
            for batch_prediction in client.batch_predictions.retrieve_results(
                "batch_prediction_id",
            ):
              print(batch_prediction)
components:
  schemas:
    BatchPredictionResultLine:
      type: object
      description: One NDJSON result line for a submitted batch item.
      required:
        - object
        - batch_id
        - custom_id
        - status
        - output
        - error
      properties:
        object:
          type: string
          enum:
            - batch_prediction.result
          description: The object type, which is always `batch_prediction.result`.
        batch_id:
          type: string
          description: The batch prediction id.
        custom_id:
          type: string
          description: The caller-defined item id from the create request.
        status:
          $ref: '#/components/schemas/BatchPredictionResultStatus'
        output:
          type: object
          additionalProperties: true
          nullable: true
          description: The model output when `status` is `succeeded`; otherwise `null`.
        error:
          allOf:
            - $ref: '#/components/schemas/ProblemDetails'
          nullable: true
          description: >-
            Problem details when `status` is `errored`, `canceled`, or
            `expired`; otherwise `null`.
      example:
        object: batch_prediction.result
        batch_id: bpred_abc123
        custom_id: drawing_001
        status: succeeded
        output:
          project_name: Alpha Office
          sheet_title: Title Sheet
          revision: R3
        error: null
    ProblemDetails:
      type: object
      required:
        - type
        - title
        - status
      properties:
        type:
          type: string
          format: uri
        title:
          type: string
        status:
          type: integer
        detail:
          type: string
        instance:
          type: string
          format: uri-reference
    BatchPredictionResultStatus:
      type: string
      description: Terminal status for an individual result line.
      enum:
        - succeeded
        - errored
        - canceled
        - expired
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````