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:Cohere ai Cohere python Batch Model

From Leeroopedia
Revision as of 12:16, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Cohere_ai_Cohere_python_Batch_Model.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains SDK, Batch Processing
Last Updated 2026-02-15 14:00 GMT

Overview

The Batch class is a Pydantic model representing a batch job resource in the Cohere Python SDK.

Description

The Batch model encapsulates all properties of a batch processing job, including its identifier, name, status, timestamps, associated dataset references, token counts, record counts, and the model used for processing. It extends UncheckedBaseModel and is auto-generated from the Cohere API definition by Fern. Most fields are read-only and populated by the server, while name, input_dataset_id, and model are required fields set at creation time. The status field uses the BatchStatus type alias, which is a string literal union representing lifecycle stages such as BATCH_STATUS_QUEUED, BATCH_STATUS_IN_PROGRESS, BATCH_STATUS_COMPLETED, BATCH_STATUS_FAILED, and BATCH_STATUS_CANCELED.

Usage

Use this model when working with the Cohere Batch API to create, monitor, or retrieve batch processing jobs. It is returned by batch-related API methods and can be used to inspect job progress, check completion status, and access output dataset references.

Code Reference

Source Location

Signature

class Batch(UncheckedBaseModel):
    id: typing.Optional[str] = pydantic.Field(default=None)
    name: str = pydantic.Field()
    creator_id: typing.Optional[str] = pydantic.Field(default=None)
    org_id: typing.Optional[str] = pydantic.Field(default=None)
    status: typing.Optional[BatchStatus] = pydantic.Field(default=None)
    created_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    updated_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    input_dataset_id: str = pydantic.Field()
    output_dataset_id: typing.Optional[str] = None
    input_tokens: typing.Optional[str] = pydantic.Field(default=None)
    output_tokens: typing.Optional[str] = pydantic.Field(default=None)
    model: str = pydantic.Field()
    num_records: typing.Optional[int] = pydantic.Field(default=None)
    num_successful_records: typing.Optional[int] = pydantic.Field(default=None)
    num_failed_records: typing.Optional[int] = pydantic.Field(default=None)
    status_reason: typing.Optional[str] = pydantic.Field(default=None)

Import

from cohere.batches.types import Batch

I/O Contract

Field Type Required Default Description
id Optional[str] No None Read-only. Batch ID.
name str Yes - Batch name (e.g. foobar).
creator_id Optional[str] No None Read-only. User ID of the creator.
org_id Optional[str] No None Read-only. Organization ID.
status Optional[BatchStatus] No None Read-only. Current stage in the life-cycle of the batch. One of: BATCH_STATUS_UNSPECIFIED, BATCH_STATUS_QUEUED, BATCH_STATUS_IN_PROGRESS, BATCH_STATUS_CANCELING, BATCH_STATUS_COMPLETED, BATCH_STATUS_FAILED, BATCH_STATUS_CANCELED.
created_at Optional[datetime] No None Read-only. Creation timestamp.
updated_at Optional[datetime] No None Read-only. Latest update timestamp.
input_dataset_id str Yes - ID of the dataset the batch reads inputs from.
output_dataset_id Optional[str] No None ID of the output dataset produced by the batch.
input_tokens Optional[str] No None Read-only. The total number of input tokens in the batch.
output_tokens Optional[str] No None Read-only. The total number of output tokens in the batch.
model str Yes - The name of the model the batch uses.
num_records Optional[int] No None Read-only. The total number of records in the batch.
num_successful_records Optional[int] No None Read-only. The current number of successful records in the batch.
num_failed_records Optional[int] No None Read-only. The current number of failed records in the batch.
status_reason Optional[str] No None Read-only. More details about the reason for the status of a batch job.

Usage Examples

import cohere

client = cohere.Client(api_key="YOUR_API_KEY")

# Create a batch job
batch = client.batches.create(
    name="my-batch-job",
    input_dataset_id="dataset-abc123",
    model="command-r-plus",
)

# Inspect the returned Batch object
print(batch.id)            # e.g. "batch-xyz789"
print(batch.status)        # e.g. "BATCH_STATUS_QUEUED"
print(batch.created_at)    # e.g. datetime(2026, 2, 15, 14, 0, 0)

# Retrieve an existing batch to check progress
batch = client.batches.get(batch_id="batch-xyz789")
print(batch.num_records)              # e.g. 1000
print(batch.num_successful_records)   # e.g. 950
print(batch.num_failed_records)       # e.g. 50
print(batch.output_dataset_id)        # e.g. "dataset-out456"

Related Pages

Page Connections

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