SAP HANA Cloud AI_CORE_REQUEST: Call AI Core Models from SQL (2026)

Quick answer: SAP HANA Cloud QRC 3/2026 introduced AI_CORE_REQUEST, a SQL function that can call a foundation-model deployment registered in SAP AI Core. It accepts a model, a messages array and optional inference parameters, then returns a structured response. This enables classification, summarization and data enrichment close to the database—but it also requires careful security, cost and data-governance controls.

Release note: This guide covers SAP HANA Cloud QRC 3/2026. Exact signatures, supported models and privileges can change, so validate the current SQL reference and your tenant before using the examples.

What is AI_CORE_REQUEST?

AI_CORE_REQUEST lets SQL invoke a foundation model managed through SAP AI Core. Traditionally, an application service had to read database data, call an external model API, parse the response and write the result back. The new function can reduce that application-layer plumbing for selected use cases.

The request contains three important parts:

  • Model/deployment: the approved AI Core foundation model to call.
  • Messages: system and user instructions plus the business text.
  • Inference parameters: options such as output length or randomness, when the selected model supports them.

Architecture in one minute

  1. A SQL statement selects approved business text or metadata.
  2. HANA Cloud sends a governed request to the configured SAP AI Core model.
  3. The model produces a structured response.
  4. SQL extracts the required value and returns or stores it.
  5. Application and data-governance rules decide whether the result may be used automatically or needs review.

Conceptual SQL pattern

-- Conceptual pattern: verify the exact QRC 3/2026 signature
SELECT AI_CORE_REQUEST(
         <approved_model>,
         <messages_json_array>,
         <optional_inference_parameters>
       ) AS model_response
FROM DUMMY;

This deliberately uses placeholders because deployment identifiers, model parameters and the exact supported syntax depend on your SAP HANA Cloud and SAP AI Core configuration. Never paste service credentials into SQL source or a blog example.

Practical use case 1: support-ticket classification

Suppose a table contains a short ticket description. The model can return a controlled category such as BILLING, DELIVERY, TECHNICAL or OTHER. A strong prompt should restrict the output:

System: Classify enterprise support tickets.
Return valid JSON only.
Allowed categories: BILLING, DELIVERY, TECHNICAL, OTHER.
Do not include personal data in the explanation.

User: <sanitized ticket text>

Validate the returned category with a SQL allowlist before storing it. A model response is untrusted input even when it comes from an approved deployment.

Practical use case 2: safe summarization

For long internal notes, request a short operational summary with a fixed maximum length and no invented actions. Keep source identifiers separate from the text passed to the model so the prompt contains only what is necessary.

  • Remove names, email addresses and account numbers unless explicitly required and permitted.
  • Limit the number and size of rows processed in one job.
  • Store model name, prompt version and execution time for traceability.
  • Show the original text to a reviewer when the summary drives a business decision.

Practical use case 3: AI-derived columns

SAP’s September 2026 HANA Cloud update notes that model inference can be connected to a generated-column scenario so inserts or updates can refresh AI-derived attributes. This is convenient, but it can also create hidden cost and latency for write-heavy tables.

Before choosing this pattern, answer these questions:

  1. How many inserts and updates happen per hour?
  2. Can the transaction tolerate model latency or temporary AI Core unavailability?
  3. Should a retry produce a new result or reuse the original one?
  4. How will you reprocess rows after changing the model or prompt?
  5. What happens when the response is invalid JSON?

For high-volume workloads, a controlled batch or queue may be safer than automatic inference on every write.

AI_CORE_REQUEST vs AI_TEXT_COMPLETION

AreaAI_CORE_REQUESTAI_TEXT_COMPLETION
Request styleMessages array plus optional inference parametersPrompt-oriented text completion
Model accessFoundation model registered in SAP AI CoreLLM service through GenAI hub and a configured remote source
Best fitChat-style requests and structured model responsesStraightforward prompt-to-text completion
Release checkConfirm QRC 3/2026 support and exact signatureConfirm supported model, remote source and privileges

Security checklist

  • Least privilege: grant execution only to the application role that needs it.
  • Approved models: allowlist deployments and model versions.
  • Data minimization: send only the columns and rows necessary for the task.
  • Prompt-injection defense: treat database text and model output as untrusted.
  • Output validation: enforce JSON schemas, allowed values and maximum lengths.
  • Secrets: keep certificates and service credentials in supported secure configuration, never table columns or source code.
  • Auditability: log prompt version, model, timestamp, status and usage metadata without exposing sensitive content.
  • Human review: require approval for financial, HR, legal or customer-impacting decisions.

Cost and performance controls

  1. Filter and deduplicate rows before calling the model.
  2. Set maximum input and output sizes.
  3. Cache results when the same stable input appears repeatedly.
  4. Use a deterministic prompt and low-randomness settings for classification.
  5. Measure p50, p95 and failure latency separately from normal SQL time.
  6. Track model usage by business process and environment.
  7. Add retry limits and a dead-letter path; do not create infinite SQL retries.

Production-ready processing pattern

1. Select eligible rows with a fixed batch size.
2. Sanitize and minimize the input.
3. Call the approved model.
4. Parse and validate the structured response.
5. Save result + model + prompt version + status.
6. Route invalid or low-confidence output to review.
7. Monitor latency, failure rate and cost.

Common mistakes

  • Calling a model for every row without estimating volume and cost.
  • Sending complete business documents when only one paragraph is needed.
  • Trusting JSON simply because it parses successfully.
  • Mixing production credentials into SQL scripts.
  • Ignoring prompt and model versioning.
  • Using AI output as a final business decision without a confidence or review policy.
  • Assuming all HANA Cloud revisions support the same function signature.

Interview questions

  1. What problem does AI_CORE_REQUEST solve?
  2. When would an application-layer API call still be preferable?
  3. How do you protect sensitive table data before model inference?
  4. Why must a structured model response still be validated?
  5. What are the risks of binding inference to every insert or update?
  6. How would you measure and control model cost from SQL?

Frequently asked questions

Can AI_CORE_REQUEST call any public model API?

It is designed for foundation models registered and governed through SAP AI Core. Use only models and deployments supported by your current environment.

Does it remove the need for SAP AI Core?

No. SAP AI Core still provides the managed model deployment and related lifecycle, security and governance capabilities.

Should I run it inside an online transaction?

Only after testing latency, failure handling and cost. A queue or batch is often safer for non-interactive enrichment.

Is AI-generated data deterministic?

Not necessarily. Results can vary by model, parameters and model version. Store provenance and design a review or reprocessing strategy.

Continue learning

Official SAP references

Last reviewed: November 2026. Always check current SAP Help for your HANA Cloud revision.

Post a Comment

0 Comments