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 Create Params

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

Overview

Concrete type for the batch creation request parameters provided by the openai-python SDK.

Description

The BatchCreateParams TypedDict defines the parameters accepted by client.batches.create(). It requires a completion_window (currently only "24h"), an endpoint (one of several supported API paths), and an input_file_id pointing to a JSONL file uploaded with purpose "batch". Optional fields include metadata for key-value annotations and output_expires_after for configuring output file expiration via the nested OutputExpiresAfter TypedDict.

Usage

Import this type when you need to type-hint parameters passed to client.batches.create() or when constructing batch creation payloads programmatically.

Code Reference

Source Location

Signature

class BatchCreateParams(TypedDict, total=False):
    completion_window: Required[Literal["24h"]]
    endpoint: Required[Literal[
        "/v1/responses", "/v1/chat/completions", "/v1/embeddings",
        "/v1/completions", "/v1/moderations", "/v1/images/generations",
        "/v1/images/edits",
    ]]
    input_file_id: Required[str]
    metadata: Optional[Metadata]
    output_expires_after: OutputExpiresAfter

class OutputExpiresAfter(TypedDict, total=False):
    anchor: Required[Literal["created_at"]]
    seconds: Required[int]

Import

from openai.types import BatchCreateParams

I/O Contract

Fields

Name Type Required Description
completion_window Literal["24h"] Yes Time frame for batch processing; currently only "24h"
endpoint Literal[...] Yes API endpoint for all requests: /v1/responses, /v1/chat/completions, /v1/embeddings, /v1/completions, /v1/moderations, /v1/images/generations, /v1/images/edits
input_file_id str Yes ID of an uploaded JSONL file with batch requests (up to 50,000 requests, 200 MB)
metadata Optional[Metadata] No Up to 16 key-value pairs for additional information
output_expires_after OutputExpiresAfter No Expiration policy for output/error files

OutputExpiresAfter Fields

Name Type Required Description
anchor Literal["created_at"] Yes Anchor timestamp; only "created_at" supported
seconds int Yes Seconds after anchor before file expires (3600 to 2592000)

Usage Examples

from openai import OpenAI

client = OpenAI()

batch = client.batches.create(
    input_file_id="file-abc123",
    endpoint="/v1/chat/completions",
    completion_window="24h",
    metadata={"project": "summarization"},
    output_expires_after={
        "anchor": "created_at",
        "seconds": 86400,  # 1 day
    },
)
print(batch.id)

Related Pages

Page Connections

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