gen_ai_hub.batch_service package¶
- class gen_ai_hub.batch_service.BatchCreateRequest(*, type: Literal['llm-native'], input: BatchInput, output: BatchOutput, spec: BatchSpec)¶
Bases:
ABCBaseModelRequest body sent to
POST /llm-batch-service/v1/batches.Describes a new batch processing job: where to read input from, where to write output, and which model to use.
- Parameters:
type (Literal["llm-native"]) – Batch processing type. Currently only
"llm-native"is supported.input (
BatchInput) – Input file configuration.output (
BatchOutput) – Output directory configuration.spec (
BatchSpec) – LLM provider and model specification.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: Literal['llm-native']¶
- input: BatchInput¶
- output: BatchOutput¶
- class gen_ai_hub.batch_service.BatchInput(*, uri: str)¶
Bases:
ABCBaseModelInput configuration for a batch job.
Points to the
.jsonlfile in an object store that contains the individual LLM requests to be processed.- Parameters:
uri (str) – Fully qualified object-store URI of the input file. Must point to a
.jsonlfile (e.g.ai://my-store/input/requests.jsonl).
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- uri: str¶
- class gen_ai_hub.batch_service.BatchOutput(*, uri: str)¶
Bases:
ABCBaseModelOutput configuration for a batch job.
Points to the directory in an object store where results will be written once the job completes.
- Parameters:
uri (str) – Fully qualified object-store URI of the output directory (e.g.
ai://my-store/output/).
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- uri: str¶
- class gen_ai_hub.batch_service.BatchSpec(*, provider: str, model: str)¶
Bases:
ABCBaseModelSpecification of the LLM to use for a batch job.
- Parameters:
provider (str) – LLM provider name as registered in SAP AI Core (e.g.
"azure-openai").model (str) – Model name to use for inference (e.g.
"gpt-4.1-mini").
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- provider: str¶
- model: str¶
- class gen_ai_hub.batch_service.BatchStatus(*values)¶
Bases:
str,EnumEnumeration of possible lifecycle states for a batch job.
- Variables:
PENDING – Job has been accepted and is waiting to be scheduled.
RUNNING – Job is actively being processed.
COMPLETED – Job finished successfully.
FAILED – Job terminated with an error.
CANCELLED – Job was cancelled by the user.
CANCELLING – Cancellation has been requested and is in progress.
- PENDING = 'PENDING'¶
- RUNNING = 'RUNNING'¶
- COMPLETED = 'COMPLETED'¶
- FAILED = 'FAILED'¶
- CANCELLED = 'CANCELLED'¶
- CANCELLING = 'CANCELLING'¶
- class gen_ai_hub.batch_service.BatchCreateResponse(*, id: str, created_at: str | None = None, status: str | None = None, message: str | None = None, **extra_data: Any)¶
Bases:
ResponseBaseModelResponse returned by
POST /llm-batch-service/v1/batches.Confirms that the batch job has been accepted and provides the assigned identifier and initial status.
- Parameters:
id (str) – Unique identifier (UUID) of the created batch job.
created_at (str, optional) – ISO 8601 timestamp of when the job was created.
status (str, optional) – Initial status of the job, typically
"PENDING".message (str, optional) – Human-readable confirmation message from the service.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- id: str¶
- created_at: str | None¶
- status: str | None¶
- message: str | None¶
- class gen_ai_hub.batch_service.BatchSummary(*, id: str, type: str | None = None, provider: str | None = None, created_at: str | None = None, status: str | None = None, **extra_data: Any)¶
Bases:
ResponseBaseModelSummary entry for a single batch job as returned in a list response.
- Parameters:
id (str) – Unique identifier (UUID) of the batch job.
type (str, optional) – Batch processing type (e.g.
"llm-native").provider (str, optional) – LLM provider name (e.g.
"azure-openai").created_at (str, optional) – ISO 8601 timestamp of when the job was created.
status (str, optional) – Current status of the job.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- id: str¶
- type: str | None¶
- provider: str | None¶
- created_at: str | None¶
- status: str | None¶
- class gen_ai_hub.batch_service.BatchListResponse(*, count: int | None = None, resources: list[BatchSummary] | None = None, **extra_data: Any)¶
Bases:
ResponseBaseModelResponse returned by
GET /llm-batch-service/v1/batches.Contains a count and a list of batch job summaries for the current resource group.
- Parameters:
count (int, optional) – Total number of batch jobs.
resources (list[
BatchSummary], optional) – List of batch job summaries.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- count: int | None¶
- resources: list[BatchSummary] | None¶
- class gen_ai_hub.batch_service.BatchStatusDetail(*, current_status: str | None = None, target_status: str | None = None, updated_at: str | None = None, message: str | None = None, **extra_data: Any)¶
Bases:
ResponseBaseModelStatus block embedded inside
BatchDetailResponse.- Parameters:
current_status (str, optional) – The job’s current lifecycle status.
target_status (str, optional) – The terminal status the job is expected to reach.
updated_at (str, optional) – ISO 8601 timestamp of the last status change.
message (str, optional) – Optional human-readable description of the current status.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- current_status: str | None¶
- target_status: str | None¶
- updated_at: str | None¶
- message: str | None¶
- class gen_ai_hub.batch_service.BatchInputDetail(*, uri: str | None = None, **extra_data: Any)¶
Bases:
ResponseBaseModelInput configuration as returned in a batch detail response.
- Parameters:
uri (str, optional) – Object-store URI of the input
.jsonlfile.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- uri: str | None¶
- class gen_ai_hub.batch_service.BatchOutputDetail(*, uri: str | None = None, **extra_data: Any)¶
Bases:
ResponseBaseModelOutput configuration as returned in a batch detail response.
- Parameters:
uri (str, optional) – Object-store URI of the output directory.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- uri: str | None¶
- class gen_ai_hub.batch_service.BatchDetailResponse(*, id: str | None = None, type: str | None = None, provider: str | None = None, created_at: str | None = None, input: BatchInputDetail | None = None, output: BatchOutputDetail | None = None, spec: dict | None = None, status: BatchStatusDetail | None = None, **extra_data: Any)¶
Bases:
ResponseBaseModelResponse returned by
GET /llm-batch-service/v1/batches/{batch_id}.Provides the full configuration and current status of a specific batch job.
- Parameters:
id (str, optional) – Unique identifier (UUID) of the batch job.
type (str, optional) – Batch processing type (e.g.
"llm-native").provider (str, optional) – LLM provider name (e.g.
"azure-openai").created_at (str, optional) – ISO 8601 timestamp of when the job was created.
input (
BatchInputDetail, optional) – Input file configuration.output (
BatchOutputDetail, optional) – Output directory configuration.spec (dict, optional) – Raw job specification dict as stored by the service.
status (
BatchStatusDetail, optional) – Current status details.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- id: str | None¶
- type: str | None¶
- provider: str | None¶
- created_at: str | None¶
- input: BatchInputDetail | None¶
- output: BatchOutputDetail | None¶
- spec: dict | None¶
- status: BatchStatusDetail | None¶
- class gen_ai_hub.batch_service.BatchStatusResponse(*, current_status: str | None = None, target_status: str | None = None, updated_at: str | None = None, message: str | None = None, **extra_data: Any)¶
Bases:
ResponseBaseModelResponse returned by
GET /llm-batch-service/v1/batches/{batch_id}/status.- Parameters:
current_status (str, optional) – The job’s current lifecycle status.
target_status (str, optional) – The terminal status the job is expected to reach.
updated_at (str, optional) – ISO 8601 timestamp of the last status change.
message (str, optional) – Optional human-readable description of the current status.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- current_status: str | None¶
- target_status: str | None¶
- updated_at: str | None¶
- message: str | None¶
- class gen_ai_hub.batch_service.BatchCancelResponse(*, id: str | None = None, created_at: str | None = None, message: str | None = None, **extra_data: Any)¶
Bases:
ResponseBaseModelResponse returned by
PATCH /llm-batch-service/v1/batches/{batch_id}/cancel.Confirms that the cancellation request has been accepted. The job will transition to
CANCELLINGand eventuallyCANCELLED.- Parameters:
id (str, optional) – Unique identifier (UUID) of the batch job.
created_at (str, optional) – ISO 8601 timestamp of when the job was originally created.
message (str, optional) – Human-readable confirmation that cancellation was scheduled.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- id: str | None¶
- created_at: str | None¶
- message: str | None¶
- class gen_ai_hub.batch_service.BatchDeleteResponse(*, id: str | None = None, created_at: str | None = None, message: str | None = None, **extra_data: Any)¶
Bases:
ResponseBaseModelResponse returned by
DELETE /llm-batch-service/v1/batches/{batch_id}.Confirms that the batch job record has been deleted. Only jobs in a terminal state (
COMPLETED,FAILED, orCANCELLED) can be deleted.- Parameters:
id (str, optional) – Unique identifier (UUID) of the deleted batch job.
created_at (str, optional) – ISO 8601 timestamp of when the job was originally created.
message (str, optional) – Human-readable confirmation of the deletion.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- id: str | None¶
- created_at: str | None¶
- message: str | None¶
- class gen_ai_hub.batch_service.ErrorResponse(*, request_id: str, message: str, **extra_data: Any)¶
Bases:
ResponseBaseModelError response body returned by the batch service on 4xx/5xx responses.
- Parameters:
request_id (str) – Unique request identifier, useful for tracing the error in service logs.
message (str) – Human-readable description of the error.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow', 'frozen': False}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- request_id: str¶
- message: str¶
- class gen_ai_hub.batch_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)¶
- 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 aclose_http_connection() None¶
Close the underlying asynchronous httpx client.
- 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 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.
- 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 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.
- 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.
- close_http_connection() None¶
Close the underlying synchronous httpx client.
- 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.
- 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.
- 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.
- 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.
- exception gen_ai_hub.batch_service.BatchServiceError(request_id: str, message: str, status_code: int, headers: Headers)¶
Bases:
ExceptionRaised when the batch service returns an error response.
Captures the request_id from the error payload for tracing.
- __init__(request_id: str, message: str, status_code: int, headers: Headers)¶
Subpackages¶
- gen_ai_hub.batch_service.models package
ABCBaseModelResponseBaseModelBatchCreateRequestBatchInputBatchOutputBatchSpecBatchStatusBatchCreateResponseBatchSummaryBatchListResponseBatchStatusDetailBatchInputDetailBatchOutputDetailBatchDetailResponseBatchStatusResponseBatchCancelResponseBatchDeleteResponseErrorResponse- Submodules
Submodules¶
- gen_ai_hub.batch_service.exceptions module
- gen_ai_hub.batch_service.service module
BatchServiceBatchService.__init__()BatchService.create()BatchService.list()BatchService.get()BatchService.get_status()BatchService.cancel()BatchService.delete()BatchService.acreate()BatchService.alist()BatchService.aget()BatchService.aget_status()BatchService.acancel()BatchService.adelete()BatchService.close_http_connection()BatchService.aclose_http_connection()