| 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 |
|
||
| f1_keywords |
|
||
| helpviewer_keywords |
|
||
| dev_langs |
|
||
| monikerRange | =fabric |
[!INCLUDE fabric-se-dw]
AI_GENERATE_RESPONSE generates text from a prompt and optional supporting data.
Note
AI_GENERATE_RESPONSEis in preview.AI_GENERATE_RESPONSEis available only in [!INCLUDE fabric-se-short] and [!INCLUDE fabric-dw].
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
AI_GENERATE_RESPONSE ( prompt [ , data ] )
An expression of a character type that defines the instruction.
Optional text input used as supporting context for the prompt.
Returns nvarchar(max) with generated text.
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.
SELECT ai_generate_response('Reply in 20 words:', 'The room was noisy.') AS response;SELECT review_id,
ai_generate_response('Draft a professional response in 30 words:', review_text) AS response_text
FROM dbo.hotel_reviews;