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:
objectClient 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-Groupheader is injected automatically fromproxy_client.request_headeron 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 fromproxy_client.proxy_client (
GenAIHubProxyClient) – AGenAIHubProxyClientinstance. Defaults to the result ofget_proxy_client(proxy_version="gen-ai-hub").resource_group (str, Optional) – Value for the
AI-Resource-Groupheader. Falls back to the resource group onproxy_clientwhen 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
.jsonlfile 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:
BatchCreateResponsewith 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:
BatchListResponsecontaining 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:
BatchDetailResponsewith 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:
BatchStatusResponsewith 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:
BatchCancelResponseconfirming 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:
BatchDeleteResponseconfirming 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
.jsonlfile 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:
BatchCreateResponsewith 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:
BatchListResponsecontaining 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:
BatchDetailResponsewith 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:
BatchStatusResponsewith 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:
BatchCancelResponseconfirming 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:
BatchDeleteResponseconfirming the deletion.
- close_http_connection() None¶
Close the underlying synchronous httpx client.
- async aclose_http_connection() None¶
Close the underlying asynchronous httpx client.