> ## 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

> Retrieves a batch prediction by id. Terminal batches include a `results_url` until retained result lines are cleaned up.



## OpenAPI

````yaml get /batch-predictions/{batch_prediction_id}
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}:
    get:
      tags:
        - Batch Predictions
      summary: Retrieve batch prediction
      description: >-
        Retrieves a batch prediction by id. Terminal batches include a
        `results_url` until retained result lines are cleaned up.
      operationId: BatchPredictions.retrieveBatchPrediction
      parameters:
        - name: batch_prediction_id
          in: path
          required: true
          description: The id of the batch prediction to retrieve.
          schema:
            type: string
      responses:
        '200':
          description: Retrieved batch prediction
          headers:
            X-Request-Id:
              description: Request identifier for tracing and support.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BatchPrediction'
        '401':
          description: >-
            Unauthorized. Authentication is required to retrieve a batch
            prediction.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '404':
          description: >-
            Not found. The requested batch prediction does not exist, or the
            authenticated user does not have permission to access it.
          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 batchPrediction = await
            client.batchPredictions.retrieve('batch_prediction_id');


            console.log(batchPrediction.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
            )
            batch_prediction = client.batch_predictions.retrieve(
                "batch_prediction_id",
            )
            print(batch_prediction.id)
components:
  schemas:
    BatchPrediction:
      type: object
      description: >-
        The `batch_prediction` object represents an asynchronous batch
        prediction job.
      required:
        - object
        - id
        - status
        - model
        - completion_window
        - created_at
        - expires_at
        - in_progress_at
        - finalizing_at
        - completed_at
        - failed_at
        - cancelling_at
        - cancelled_at
        - expired_at
        - request_counts
        - metadata
        - error
        - results_url
      properties:
        object:
          type: string
          enum:
            - batch_prediction
          description: The object type, which is always `batch_prediction`.
        id:
          type: string
          description: The id of the batch prediction.
        status:
          $ref: '#/components/schemas/BatchPredictionStatus'
        model:
          $ref: '#/components/schemas/BatchPredictionModel'
        completion_window:
          type: string
          enum:
            - 24h
          description: Requested completion window.
        created_at:
          type: string
          format: date-time
          description: ISO timestamp when the batch was created.
        expires_at:
          type: string
          format: date-time
          description: ISO timestamp when the batch completion window expires.
        in_progress_at:
          type: string
          format: date-time
          nullable: true
          description: >-
            ISO timestamp when the batch entered `in_progress`, or `null` if it
            has not.
        finalizing_at:
          type: string
          format: date-time
          nullable: true
          description: >-
            ISO timestamp when the batch entered `finalizing`, or `null` if it
            has not.
        completed_at:
          type: string
          format: date-time
          nullable: true
          description: >-
            ISO timestamp when the batch reached `completed`, or `null`
            otherwise.
        failed_at:
          type: string
          format: date-time
          nullable: true
          description: ISO timestamp when the batch reached `failed`, or `null` otherwise.
        cancelling_at:
          type: string
          format: date-time
          nullable: true
          description: ISO timestamp when cancellation was requested, or `null` otherwise.
        cancelled_at:
          type: string
          format: date-time
          nullable: true
          description: >-
            ISO timestamp when the batch reached `cancelled`, or `null`
            otherwise.
        expired_at:
          type: string
          format: date-time
          nullable: true
          description: ISO timestamp when the batch reached `expired`, or `null` otherwise.
        request_counts:
          $ref: '#/components/schemas/BatchPredictionRequestCounts'
        metadata:
          $ref: '#/components/schemas/Metadata'
        error:
          allOf:
            - $ref: '#/components/schemas/ProblemDetails'
          nullable: true
          description: >-
            Batch-level terminal error details for `failed`, `cancelled`, or
            `expired` batches; otherwise `null`.
        results_url:
          type: string
          format: uri-reference
          nullable: true
          description: >-
            Relative URL for the NDJSON results stream once the batch is
            terminal. This becomes `null` after retained result lines are
            cleaned up.
      example:
        object: batch_prediction
        id: bpred_abc123
        status: completed
        model: gemini-2.5-flash
        completion_window: 24h
        created_at: '2026-04-10T12:00:00.000Z'
        expires_at: '2026-04-11T12:00:00.000Z'
        in_progress_at: '2026-04-10T12:01:00.000Z'
        finalizing_at: '2026-04-10T12:05:00.000Z'
        completed_at: '2026-04-10T12:06:00.000Z'
        failed_at: null
        cancelling_at: null
        cancelled_at: null
        expired_at: null
        request_counts:
          total: 2
          processing: 0
          succeeded: 2
          errored: 0
          canceled: 0
          expired: 0
        metadata:
          project: alpha
        error: null
        results_url: /v1/batch-predictions/bpred_abc123/results
    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
    BatchPredictionStatus:
      type: string
      description: >-
        Current batch lifecycle state. Terminal states are `completed`,
        `failed`, `expired`, and `cancelled`.
      enum:
        - validating
        - failed
        - in_progress
        - finalizing
        - completed
        - expired
        - cancelling
        - cancelled
    BatchPredictionModel:
      type: string
      description: >-
        LLM model to use for every item in the batch. Model availability is
        cloud-aware: AWS teamspaces accept Bedrock-native batch-capable models,
        while GCP teamspaces accept non-Bedrock batch-capable models and reject
        Bedrock-only ids. Deprecated gemini-2.0-flash is accepted for backward
        compatibility and automatically runs as gemini-3.1-flash-lite.
      enum:
        - gemini-2.0-flash
        - gemini-2.5-flash
        - gemini-2.5-flash-lite
        - gemini-3.1-flash-lite
        - gemini-3.5-flash
        - gemini-2.5-pro
        - gemini-3.1-pro-preview
        - gpt-4o
        - gpt-4o-mini
        - gpt-4.1-mini
        - gpt-4.1
        - gpt-5-mini
        - gpt-5
        - gpt-5.1
        - claude-sonnet-4@20250514
        - claude-opus-4-1@20250805
        - claude-haiku-4-5@20251001
        - claude-sonnet-4-5@20250929
        - claude-sonnet-4-6@default
        - claude-opus-4-5@20251101
        - claude-opus-4-6@default
        - claude-opus-4-7
        - claude-opus-4-8
        - anthropic.claude-haiku-4-5-20251001-v1:0
        - anthropic.claude-sonnet-4-5-20250929-v1:0
        - anthropic.claude-sonnet-4-6
        - anthropic.claude-opus-4-5-20251101-v1:0
        - anthropic.claude-opus-4-6-v1
        - anthropic.claude-opus-4-7
        - anthropic.claude-opus-4-8
        - amazon.nova-2-lite-v1:0
    BatchPredictionRequestCounts:
      type: object
      required:
        - total
        - processing
        - succeeded
        - errored
        - canceled
        - expired
      properties:
        total:
          type: integer
          minimum: 0
          description: Total number of submitted items.
        processing:
          type: integer
          minimum: 0
          description: Items that are still pending or processing.
        succeeded:
          type: integer
          minimum: 0
          description: Items that completed with a valid output.
        errored:
          type: integer
          minimum: 0
          description: Items that ended with an error.
        canceled:
          type: integer
          minimum: 0
          description: Items that were cancelled before completion.
        expired:
          type: integer
          minimum: 0
          description: Items that did not finish before the completion window elapsed.
      description: >-
        The sum of processing, succeeded, errored, canceled, and expired equals
        total.
    Metadata:
      type: object
      description: >-
        Optional metadata map with up to 16 entries. Metadata keys must be 64
        characters or fewer and values must be 512 characters or fewer.
      maxProperties: 16
      additionalProperties:
        type: string
        maxLength: 512
      nullable: true
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````