gen_ai_hub.batch_service.service module

Client for the LLM Batch Service API.

Provides synchronous and asynchronous methods to create, list, inspect, cancel, and delete batch processing jobs via SAP AI Core.

class gen_ai_hub.batch_service.service.BatchService(api_url: str | None = None, proxy_client: GenAIHubProxyClient | None = None, resource_group: str | None = None, timeout: int | float | Timeout | None = None)

Bases: object

Client for the LLM Batch Service API.

Supports synchronous and asynchronous variants of all five operations: create, list, get, cancel, and delete batch jobs.

The AI-Resource-Group header is injected automatically from proxy_client.request_header on every request.

Parameters:
  • api_url (str, Optional) – Base URL of the SAP AI Core API (e.g. https://api.ai.prod.eu-central-1.aws.ml.hana.ondemand.com/v2). Defaults to the URL resolved from proxy_client.

  • proxy_client (GenAIHubProxyClient) – A GenAIHubProxyClient instance. Defaults to the result of get_proxy_client(proxy_version="gen-ai-hub").

  • resource_group (str, Optional) – Value for the AI-Resource-Group header. Falls back to the resource group on proxy_client when omitted.

  • timeout (Union[int, float, httpx.Timeout], Optional) – Default HTTP request timeout passed to httpx.

__init__(api_url: str | None = None, proxy_client: GenAIHubProxyClient | None = None, resource_group: str | None = None, timeout: int | float | Timeout | None = None)
create(*, type: str, input_uri: str, output_uri: str, provider: str, model: str, timeout: int | float | Timeout | None = None) BatchCreateResponse

Create a new batch processing job.

Parameters:
  • type (str) – Batch processing type (only "llm-native" is supported).

  • input_uri (str) – URI of the input .jsonl file in the object store.

  • output_uri (str) – URI of the output directory in the object store.

  • provider (str) – LLM provider name (e.g. "azure-openai").

  • model (str) – Model name (e.g. "gpt-4.1-mini").

  • timeout (Union[int, float, httpx.Timeout], Optional) – Per-request timeout override.

Returns:

BatchCreateResponse with the job ID and initial status.

list(timeout: int | float | Timeout | None = None) BatchListResponse

List all batch jobs for the current resource group.

Parameters:

timeout (Union[int, float, httpx.Timeout], Optional) – Per-request timeout override.

Returns:

BatchListResponse containing the batch summaries.

get(batch_id: str, timeout: int | float | Timeout | None = None) BatchDetailResponse

Retrieve details of a specific batch job.

Parameters:
  • batch_id (str) – UUID of the batch job.

  • timeout (Union[int, float, httpx.Timeout], Optional) – Per-request timeout override.

Returns:

BatchDetailResponse with full job details.

get_status(batch_id: str, timeout: int | float | Timeout | None = None) BatchStatusResponse

Retrieve the current status of a batch job.

Parameters:
  • batch_id (str) – UUID of the batch job.

  • timeout (Union[int, float, httpx.Timeout], Optional) – Per-request timeout override.

Returns:

BatchStatusResponse with current and target status.

cancel(batch_id: str, timeout: int | float | Timeout | None = None) BatchCancelResponse

Schedule a batch job for cancellation.

Parameters:
  • batch_id (str) – UUID of the batch job.

  • timeout (Union[int, float, httpx.Timeout], Optional) – Per-request timeout override.

Returns:

BatchCancelResponse confirming the cancellation request.

delete(batch_id: str, timeout: int | float | Timeout | None = None) BatchDeleteResponse

Delete a batch job (only allowed for terminal states: COMPLETED, FAILED, CANCELLED).

Parameters:
  • batch_id (str) – UUID of the batch job.

  • timeout (Union[int, float, httpx.Timeout], Optional) – Per-request timeout override.

Returns:

BatchDeleteResponse confirming the deletion.

async acreate(*, type: str = 'llm-native', input_uri: str, output_uri: str, provider: str, model: str, timeout: int | float | Timeout | None = None) BatchCreateResponse

Async variant of create().

Parameters:
  • type (str) – Batch processing type (only "llm-native" is supported).

  • input_uri (str) – URI of the input .jsonl file in the object store.

  • output_uri (str) – URI of the output directory in the object store.

  • provider (str) – LLM provider name (e.g. "azure-openai").

  • model (str) – Model name (e.g. "gpt-4.1-mini").

  • timeout (Union[int, float, httpx.Timeout], Optional) – Per-request timeout override.

Returns:

BatchCreateResponse with the job ID and initial status.

async alist(timeout: int | float | Timeout | None = None) BatchListResponse

Async variant of list().

Parameters:

timeout (Union[int, float, httpx.Timeout], Optional) – Per-request timeout override.

Returns:

BatchListResponse containing the batch summaries.

async aget(batch_id: str, timeout: int | float | Timeout | None = None) BatchDetailResponse

Async variant of get().

Parameters:
  • batch_id (str) – UUID of the batch job.

  • timeout (Union[int, float, httpx.Timeout], Optional) – Per-request timeout override.

Returns:

BatchDetailResponse with full job details.

async aget_status(batch_id: str, timeout: int | float | Timeout | None = None) BatchStatusResponse

Async variant of get_status().

Parameters:
  • batch_id (str) – UUID of the batch job.

  • timeout (Union[int, float, httpx.Timeout], Optional) – Per-request timeout override.

Returns:

BatchStatusResponse with current and target status.

async acancel(batch_id: str, timeout: int | float | Timeout | None = None) BatchCancelResponse

Async variant of cancel().

Parameters:
  • batch_id (str) – UUID of the batch job.

  • timeout (Union[int, float, httpx.Timeout], Optional) – Per-request timeout override.

Returns:

BatchCancelResponse confirming the cancellation request.

async adelete(batch_id: str, timeout: int | float | Timeout | None = None) BatchDeleteResponse

Async variant of delete().

Parameters:
  • batch_id (str) – UUID of the batch job.

  • timeout (Union[int, float, httpx.Timeout], Optional) – Per-request timeout override.

Returns:

BatchDeleteResponse confirming the deletion.

close_http_connection() None

Close the underlying synchronous httpx client.

async aclose_http_connection() None

Close the underlying asynchronous httpx client.