Implementation:Openai Openai python Batch Error Model
| 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
- Repository: openai-python
- File: src/openai/types/batch_error.py
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})")