Skip to content

Latest commit

 

History

History
84 lines (62 loc) · 2.53 KB

File metadata and controls

84 lines (62 loc) · 2.53 KB
title AI_GENERATE_RESPONSE (Transact-SQL)
description The AI_GENERATE_RESPONSE function generates a response from a prompt and optional context data.
author WilliamDAssafMSFT
ms.author wiassaf
ms.reviewer jovanpop
ms.date 06/11/2026
ms.service sql
ms.subservice t-sql
ms.topic reference
ms.custom
sql-ai
f1_keywords
ai_generate_response_TSQL
ai_generate_response
helpviewer_keywords
ai_generate_response
dev_langs
TSQL
monikerRange =fabric

AI_GENERATE_RESPONSE (Transact-SQL)

[!INCLUDE fabric-se-dw]

AI_GENERATE_RESPONSE generates text from a prompt and optional supporting data.

Note

  • AI_GENERATE_RESPONSE is in preview.
  • AI_GENERATE_RESPONSE is available only in [!INCLUDE fabric-se-short] and [!INCLUDE fabric-dw].

Syntax

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

AI_GENERATE_RESPONSE ( prompt [ , data ] )

Arguments

prompt

An expression of a character type that defines the instruction.

data

Optional text input used as supporting context for the prompt.

Return types

Returns nvarchar(max) with generated text.

Remarks

AI functions return NULL if the AI model can't process the text. Common reasons include:

  • Responsible AI rules block inappropriate content in the input text.
  • Input text exceeds token limits. The current model supports up to 15 KB of text.

Examples

A. Generate a short response

SELECT ai_generate_response('Reply in 20 words:', 'The room was noisy.') AS response;

B. Generate responses per row

SELECT review_id,
       ai_generate_response('Draft a professional response in 30 words:', review_text) AS response_text
FROM dbo.hotel_reviews;

Related content