Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Share your ideas and vote for future features

0 Votes
Status: New
0 Votes
Status: New
0 Votes
Status: New
0 Votes
Status: New
0 Votes
Status: New
0 Votes
Status: New
0 Votes
Status: New
0 Votes
Status: New
0 Votes
Status: New
0 Votes
Status: New
0 Votes
Status: New
0 Votes
Status: Completed

Please check this learn document - sp_invoke_external_rest_endpoint (Transact-SQL) - SQL Server | Microsoft Learn

Also, Here's a sample code

 DECLARE @url nvarchar(4000) = '<URL for Chat GPT model that you have deployed>';
    DECLARE @payload nvarchar(max) = N'{
        "messages": [
            {
                "role": "system",
                "content": "You are a sales assistant who helps customers find the right products for their question and activities."
            },
            {
                "role": "user",
                "content": "The products available are the following: ' + <Data to ground your ask> + '"
            },
            {
                "role": "user",
                "content": " ' + <add the prompt> + '"
            }
        ]
    }';

    DECLARE @ret int, @response nvarchar(max);

    exec @ret = sp_invoke_external_rest_endpoint
        @url = @url,
        @method = 'POST',
        @payload = @payload,
        @Credential = [<Add your Credential>],    
        @timeout = 230,
        @response = @response output;

    select json_value(@response, '$.result.choices[0].message.content');
0 Votes
Status: New
0 Votes
Status: New
0 Votes
Status: New
0 Votes
Status: New
0 Votes
Status: New
0 Votes
Status: New
0 Votes
Status: New
0 Votes
Status: New

Helpful resources