Batch Consumption
Prerequisites
- BTP Account
Set up your SAP Business Technology Platform (BTP) account.
Create a BTP Account - For SAP Developers or Employees
Internal SAP stakeholders should refer to the following documentation: How to create BTP Account For Internal SAP Employee, SAP AI Core Internal Documentation - For External Developers, Customers, or Partners
Follow this tutorial to set up your environment and entitlements: External Developer Setup Tutorial, SAP AI Core External Documentation - Create BTP Instance and Service Key for SAP AI Core
Follow the steps to create an instance and generate a service key for SAP AI Core:
Create Service Key and Instance - AI Core Setup Guide
Step-by-step guide to set up and get started with SAP AI Core:
AI Core Setup Tutorial - An Extended SAP AI Core service plan is required, as the Generative AI Hub is not available in the Free or Standard tiers. For more details, refer to
SAP AI Core Service Plans - You have an object store secret registered in SAP AI Core for one of the following providers:
- Amazon S3
- Azure Blob Storage
- Google Cloud Storage
- Alibaba Cloud OSS
For more information, see Register Your Object Store Secret
- Bruno API Client
Download Bruno from usebruno.com/downloads - SAP Batch consumption Collection
Clone the SAP Batch consumption Bruno collection from github.com PLACEHOLDER
You Will Learn
- What the supported input types are and when to use each
- How to structure a JSONL input file with multiple requests of the same input type
- How to structure a JSONL input file containing multiple input types in a single batch
- How to create and submit a batch job using Bruno
- How to monitor batch job status and retrieve results
- Step 1
What Is Batch Consumption?
Batch consumption lets you process large volumes of LLM inference requests asynchronously in SAP AI Core. You package all your requests into a single JSON Lines (
.jsonl) file, upload it to your object store, and submit it as a batch job. SAP AI Core processes the requests in the background and writes all results to your object store in a single output file when complete.When to Use Batch Consumption
Use batch consumption when:
- You have 50 or more requests to process in one run
- Your workload is not time-critical
- You want to reduce inference costs compared to synchronous calls
- You want SAP AI Core to manage retries and rate limits automatically
Do not use batch consumption when:
- You need real-time responses (for example, a user-facing chat interface)
- Your requests use orchestration pipelines — only native LLM calls are supported
Batch Consumption vs Other Asynchronous Approaches
Aspect Batch Consumption Custom Async Orchestration Message Queue Setup complexity Low — single API call Medium — custom code required High — integration design required Rate limit handling Automatic Manual Manual or platform-managed Cost Reduced vs synchronous Same as synchronous Additional platform cost Best for Bulk LLM workloads, offline processing Moderate volumes, custom workflows Event-driven, cross-system pipelines Key Constraints
- Supports native LLM calls only — orchestration requests are not supported
- All requests in a single batch job must use the same model
- Output lines are not guaranteed to be in the same order as input lines — always use
custom_idto match responses to requests
Batch Limits
Limit Value Maximum input file size 200 MB Maximum requests per file 100,000 Maximum input files (no expiry set) 500 Maximum input files (expiry set) 10,000 - Step 2
┌─────────────────────────────────────────────────────────────────────┐ │ Online Retailer — Mixed Product Inputs │ │ │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌───────────┐ │ │ │ Customer │ │ Product │ │ Product │ │ Product │ │ │ │ Review │ │ Image │ │ Image │ │ Descrip- │ │ │ │ (text) │ │ (base64) │ │ (URL) │ │ tion │ │ │ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ └─────┬─────┘ │ └─────────┼────────────────┼────────────────┼───────────────┼─────────┘ └────────────────┴────────────────┴───────────────┘ │ │ Package as JSONL ▼ ┌────────────────────────┐ │ input-batch-mixed.jsonl│ │ (4 requests) │ └────────────┬───────────┘ │ Upload ▼ ┌────────────────────────┐ │ Object Store │ │ (S3 / Azure / GCS / │ │ Alibaba OSS) │ └────────────┬───────────┘ │ ai:// URI ▼ ┌────────────────────────┐ │ SAP AI Core │ │ Batch Job │ │ POST /v1/batches │ └────────────┬───────────┘ │ Async processing ▼ ┌────────────────────────┐ │ LLM Provider │ │ (azure-openai) │ └────────────┬───────────┘ │ Results ▼ ┌────────────────────────┐ │ Object Store │ │ output/<batch_id>/ │ │ output.jsonl │ │ (single file, N lines)│ └────────────────────────┘ - Step 3
- Step 4
Generic secrets securely store object store credentials required for batch input and output file access.
- Step 5
Batch jobs require a JSON Lines (
.jsonl) file as input. Each line is a self-contained JSON object representing one inference request. Lines must not be separated by commas, and the file must end with a newline after the last line.Required Fields Per Line
Field Description custom_idUnique identifier for the request. Used to match each response to its input. methodHTTP method. Only POSTis supported.urlInference endpoint. Only /v1/chat/completionsis supported.bodyRequest body. Must include modelandmessages. Addresponse_formatfor structured output requests.Note: All requests in the file must use the same model.
Supported Input Types
The batch service supports three input types. Each uses a different structure for the
body.messages[].contentfield.Standard Text Input
The
contentfield is a plain string. Use this for text documents, Q&A, classification, or summarisation.jsonCopy{ "role": "user", "content": "Your prompt text here." }Base64 Encoded Image Input
The
contentfield is an array containing a text prompt and an image as a base64-encoded data URI. Use this when your image is stored locally or is not publicly accessible.jsonCopy{ "role": "user", "content": [ { "type": "text", "text": "Describe this image." }, { "type": "image_url", "image_url": { "url": "data:image/png;base64,<base64_string>" } } ] }Note: Base64 encoding increases the size of your JSONL file. For large images, prefer the image URL approach where possible.
Image URL Input
The
contentfield is an array containing a text prompt and a publicly accessible image URL. The LLM provider fetches the image at processing time.jsonCopy{ "role": "user", "content": [ { "type": "text", "text": "Describe this image." }, { "type": "image_url", "image_url": { "url": "https://your-public-cdn.com/image.png", "detail": "high" } } ] }Important: The image URL must be reachable by the LLM provider’s servers at processing time — not just from your browser. GitHub raw URLs, internal network URLs, and short-expiry presigned URLs will fail with a
400error. Use stable public CDN or object store URLs. - Step 6
The
input-batch-text.jsonlfile contains three text requests in a single batch job.request-1
jsonlCopy{"custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-4.1", "messages": [{"role": "system", "content": "You are a helpful assistant"}, {"role": "user", "content": "What is SAP AI Core and what are its key capabilities?"}]}}request-2
jsonlCopy{"custom_id": "request-2", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-4.1", "messages": [{"role": "system", "content": "You are a helpful assistant"}, {"role": "user", "content": "What is Agentic AI and how does it differ from traditional AI systems?"}]}}request-3
jsonlCopy{"custom_id": "request-3", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-4.1", "messages": [{"role": "system", "content": "You are a helpful assistant"}, {"role": "user", "content": "Given the following context about a facility management company:\n---\n Facility Solutions manages over 500 commercial buildings across 12 cities. Their services include HVAC maintenance, cleaning, security, and emergency repairs. They receive an average of 200 service requests daily and prioritise them based on urgency and SLA levels.\n---\nBased on this context, what AI use cases would be most valuable to implement?"}]}}Note:
request-3demonstrates how to pass a short context passage alongside a question. The context is embedded directly in theusermessage — no special formatting is required by the batch service. - Step 7
The
input-batch-mixed.jsonlfile contains four requests — one per input type.request-1 — Standard Text
jsonlCopy{"custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-4.1", "messages": [{"role": "system", "content": "You are a helpful assistant"}, {"role": "user", "content": "Analyse the following customer review and return a JSON with keys: \"sentiment\" (`positive`, `neutral`, `negative`), \"category\" (`product_quality`, `delivery`, `customer_service`, `pricing`, `general`), and \"summary\" (one sentence). Return only a valid compact JSON string.\n\nReview:\n---\nI recently purchased the wireless headphones and I am extremely satisfied with the sound quality. The noise cancellation works brilliantly, battery life lasts a full day, and delivery was prompt. Highly recommend!\n---"}]}}request-2 — Base64 Encoded Image
jsonlCopy{"custom_id": "request-2", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-4.1", "messages": [{"role": "system", "content": "You are a helpful assistant"}, {"role": "user", "content": [{"type": "text", "text": "This is a product image from our retail catalogue. Describe the product, its appearance, colour, and whether the image quality is suitable for a product listing."}, {"type": "image_url", "image_url": {"url": "data:image/png;base64,<base64_encoded_product_image>"}}]}], "max_tokens": 1000}}request-3 — Image URL
jsonlCopy{"custom_id": "request-3", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-4.1", "messages": [{"role": "system", "content": "You are a helpful assistant"}, {"role": "user", "content": [{"type": "text", "text": "This is a product image from our online catalogue. Describe the product, its key visual attributes, and whether it appears suitable for a retail product listing."}, {"type": "image_url", "image_url": {"url": "https://your-public-cdn.com/product-image.png", "detail": "high"}}]}], "max_tokens": 1000}}request-4 — Structured Output
jsonlCopy{"custom_id": "request-4", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "gpt-4.1", "messages": [{"role": "system", "content": "You are a helpful assistant"}, {"role": "user", "content": "Extract the product details from the following description:\n---\nProduct: UltraSound Pro Wireless Headphones. Premium over-ear headphones with 40-hour battery life and active noise cancellation. Available in Midnight Black and Arctic White. Currently in stock. Rated 4.7 out of 5 by over 2,300 customers. Price: $149.99.\n---"}], "response_format": {"type": "json_schema", "json_schema": {"name": "ProductDetailsResponse", "strict": true, "schema": {"type": "object", "properties": {"product_name": {"type": "string"}, "category": {"type": "string"}, "price": {"type": "string"}, "availability": {"type": "string"}, "rating": {"type": "string"}}, "required": ["product_name", "category", "price", "availability", "rating"], "additionalProperties": false}}}}}Note: For
request-2, replace<base64_encoded_product_image>with your actual base64 image string. Forrequest-3, replace the URL with a stable, publicly accessible URL reachable by the LLM provider’s servers. - Step 8
Upload your input file to your object store. SAP AI Core accesses it using the
ai://URI scheme, which maps to a registered object store secret.URI Format
ai://<object_store_secret_name>/<file_path>/<file_name>.jsonlExamples:
ai://batch-consumption/batch_input/input-batch-text.jsonl ai://batch-consumption/batch_input/input-batch-mixed.jsonlNote: Decide on your output folder URI now — you will need it in the next step. The output URI must end with
/.Example output URI:
ai://batch-consumption/batch_output/ - Step 9
- Step 10
- Step 11
Once the batch status is
COMPLETED, download the output file from your object store.Output File Location
ai://batch-consumption/batch_output/<batch_id>/output.jsonlIf any individual requests failed, an error file is written alongside:
ai://batch-consumption/batch_output/<batch_id>/error.jsonlNote: A
COMPLETEDstatus means the batch as a whole was processed. Individual requests may still have failed. Always checkresponse.status_codefor every line in the output file.Results: Batch Example 1
The output file contains three response lines — one per text request. Output order is not guaranteed — always use
custom_idto match responses to inputs.jsonlCopy{"custom_id": "request-1", "response": {"body": {"choices": [{"message": {"content": "SAP AI Core is a service within the SAP Business Technology Platform that enables lifecycle management of AI functions. Key capabilities include training and deploying AI models at scale, serving LLM inference via the Generative AI Hub, and providing observability for deployed AI workloads."}}]}, "status_code": 200}, "error": null} {"custom_id": "request-3", "response": {"body": {"choices": [{"message": {"content": "Valuable AI use cases for ProCare include: 1) Automated request triage using NLP to classify and route service requests by urgency and SLA. 2) Predictive maintenance to anticipate equipment failures. 3) Intelligent scheduling to assign technicians based on location and workload. 4) Sentiment analysis on customer communications to proactively identify dissatisfied clients."}}]}, "status_code": 200}, "error": null} {"custom_id": "request-2", "response": {"body": {"choices": [{"message": {"content": "Agentic AI refers to systems that autonomously plan and execute sequences of actions to achieve a goal — using tools, APIs, or other AI models — with minimal human intervention. Unlike traditional AI that maps a single input to a single output, agentic systems maintain goals across multiple steps, adapt based on intermediate results, and interact with external environments."}}]}, "status_code": 200}, "error": null}custom_idStatus Output request-1✅ 200Description of SAP AI Core and its capabilities request-2✅ 200Explanation of Agentic AI vs traditional AI request-3✅ 200AI use case recommendations based on the provided context Results: Batch Example 2
The output file contains four response lines — one per input type.
jsonlCopy{"custom_id": "request-1", "response": {"body": {"choices": [{"message": {"content": "{\"sentiment\":\"positive\",\"category\":\"product_quality\",\"summary\":\"The customer is highly satisfied with the sound quality, noise cancellation, battery life, and delivery of the wireless headphones.\"}"}}]}, "status_code": 200}, "error": null} {"custom_id": "request-4", "response": {"body": {"choices": [{"message": {"content": "{\"product_name\":\"UltraSound Pro Wireless Headphones\",\"category\":\"Electronics\",\"price\":\"$149.99\",\"availability\":\"In stock\",\"rating\":\"4.7 out of 5\"}"}}]}, "status_code": 200}, "error": null} {"custom_id": "request-2", "response": {"body": {"choices": [{"message": {"content": "The image appears to show a small graphical icon rather than a full product photograph. The image resolution is not suitable for a retail product listing. Please provide a high-resolution product photograph."}}]}, "status_code": 200}, "error": null} {"custom_id": "request-3", "response": {"body": {"choices": [{"message": {"content": "The image shows a pair of over-ear wireless headphones in Midnight Black. The earcups are large and padded with a sleek matte finish. The product is well-lit against a clean white background, making it suitable for a retail product listing."}}]}, "status_code": 200}, "error": null}custom_idInput Type Status Key Output request-1Standard text ✅ 200sentiment: positive,category: product_qualitywith one-line summaryrequest-2Base64 image ✅ 200Placeholder image flagged as unsuitable — provide a real product photo request-3Image URL ✅ 200Visual description of headphones — suitable for catalogue listing request-4Structured output ✅ 200Typed JSON with product_name, category, price, availability, rating Note:
status_code: 200means the request was processed without error. It does not mean the LLM produced the output you expected — always review thecontentfield. - Step 12
Get Batch Details
- Step 13
Error Codes
Error Code Description Resolution invalid_json_lineOne or more lines could not be parsed as valid JSON. Validate each line with a JSON parser before uploading. too_many_tasksRequests in the file exceed the 100,000 limit. Split into smaller files and submit separate batch jobs. url_mismatchA line has a URL that does not match /v1/chat/completions.Ensure all lines use the same endpoint. model_not_foundThe model name in the modelfield was not found.Verify the model name matches a valid deployment in your resource group. duplicate_custom_idTwo or more requests share the same custom_id.Ensure all custom_idvalues are unique across the file.empty_fileThe input file contains no requests. Ensure the file has at least one valid JSON line. model_mismatchThe modelfield differs across lines.All requests in a batch file must use the same model. invalid_requestA line is missing required fields or has an invalid schema. Check that all lines include custom_id,method,url, andbody.Note: Input JSONL files must be encoded as plain UTF-8. Files saved with a Byte-Order-Mark (BOM) — common on Windows — will fail validation. Save explicitly as UTF-8 without BOM.
- Pre-Read
- Architecture
- Connect to SAP AI Core Instance
- Register an Object Store Secret
- Prepare Your Input File
- Batch Example 1 — Multiple Requests of the Same Input Type
- Batch Example 2 — Multiple Requests of Different Input Types
- Upload Your Input File to the Object Store
- Create a Batch Job
- Check Batch Job Status
- Retrieve and Interpret Your Results
- Manage Your Batch Jobs
- Troubleshooting