Implementation:Openai Openai python Batch Completed Webhook
| Knowledge Sources | |
|---|---|
| Domains | API_Types, Python |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete tool for representing a batch completed webhook event from the OpenAI Webhooks API, provided by the openai-python SDK.
Description
BatchCompletedWebhookEvent is a Pydantic BaseModel subclass that represents the webhook event sent when a batch API request has been completed. It contains the event id, created_at timestamp, a data payload (nested Data model with the batch request id), a type field (always "batch.completed"), and an optional object field (always "event" when present). This model is used to deserialize incoming webhook payloads for batch completion notifications.
Usage
Import this type when you need to type-annotate or deserialize incoming webhook payloads for batch completion events, typically in a webhook handler endpoint to trigger downstream processing of batch results.
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/types/webhooks/batch_completed_webhook_event.py
Signature
class Data(BaseModel):
"""Event data payload."""
id: str
class BatchCompletedWebhookEvent(BaseModel):
"""Sent when a batch API request has been completed."""
id: str
created_at: int
data: Data
type: Literal["batch.completed"]
object: Optional[Literal["event"]] = None
Import
from openai.types.webhooks import BatchCompletedWebhookEvent
I/O Contract
Fields (BatchCompletedWebhookEvent)
| Name | Type | Required | Description |
|---|---|---|---|
| id | str | Yes | The unique ID of the event. |
| created_at | int | Yes | The Unix timestamp (in seconds) of when the batch API request was completed. |
| data | Data | Yes | Event data payload containing the batch request ID. |
| type | Literal["batch.completed"] | Yes | The type of the event. Always "batch.completed". |
| object | Optional[Literal["event"]] | No | The object of the event. Always "event" when present. |
Fields (Data)
| Name | Type | Required | Description |
|---|---|---|---|
| id | str | Yes | The unique ID of the batch API request. |
Usage Examples
from openai.types.webhooks import BatchCompletedWebhookEvent
# In a webhook handler (e.g., Flask/FastAPI)
def handle_webhook(payload: dict):
event = BatchCompletedWebhookEvent.model_validate(payload)
print(f"Batch {event.data.id} completed at {event.created_at}")
# Trigger downstream processing of batch results
process_batch_results(event.data.id)