Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Openai Openai python Batch Error Model

From Leeroopedia
Knowledge Sources
Domains API_Types, Python
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete type for a single batch error entry provided by the openai-python SDK.

Description

The BatchError Pydantic model represents an individual error that occurred while processing a request within a batch job. Each error contains an optional code identifying the error type, a line number in the input file where the error occurred, a human-readable message, and the param name that caused the error. All fields are optional since different error types populate different subsets.

Usage

Import this type when inspecting the errors.data list on a Batch object to understand which input lines failed and why.

Code Reference

Source Location

Signature

class BatchError(BaseModel):
    code: Optional[str] = None
    line: Optional[int] = None
    message: Optional[str] = None
    param: Optional[str] = None

Import

from openai.types import BatchError

I/O Contract

Fields

Name Type Required Description
code Optional[str] No Error code identifying the error type
line Optional[int] No Line number in the input file where the error occurred
message Optional[str] No Human-readable error description
param Optional[str] No Name of the parameter that caused the error

Usage Examples

from openai import OpenAI

client = OpenAI()

batch = client.batches.retrieve("batch_abc123")
if batch.errors and batch.errors.data:
    for error in batch.errors.data:
        print(f"[{error.code}] Line {error.line}: {error.message} (param: {error.param})")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment