File tree 1 file changed +13
-2
lines changed
Filter options
1 file changed +13
-2
lines changed
Original file line number Diff line number Diff line change
1
+ /*
2
+ Create database credentials to store API key
3
+ */
4
+ if exists (select * from sys.[database_scoped_credentials] where name = ' https://<your-app-name>.openai.azure.com/openai/deployments/<deployment-id>' )
5
+ begin
6
+ drop database scoped credential [https://<your-app-name>.openai.azure.com/openai/deployments/<deployment-id>];
7
+ end
8
+ create database scoped credential [https://<your-app-name>.openai.azure.com/openai/deployments/<deployment-id>]
9
+ with identity = ' HTTPEndpointHeaders' , secret = ' {"api-key": "<api-key>"}' ;
10
+ go
11
+
1
12
/*
2
13
Get the embeddings for the input text by calling the OpenAI API
3
14
*/
4
15
declare @inputText nvarchar (max ) = ' the foundation series by isaac asimov' ;
5
16
declare @retval int , @response nvarchar (max );
6
17
declare @payload nvarchar (max ) = json_object(' input' : @inputText);
7
18
exec @retval = sp_invoke_external_rest_endpoint
8
- @url = ' https://<your-app-name>.openai.azure.com/openai/deployments/<deployment-id>/embeddings ?api-version=2023-03-15-preview' ,
19
+ @url = ' https://<your-app-name>.openai.azure.com/openai/deployments/<deployment-id>?api-version=2023-03-15-preview' ,
9
20
@method = ' POST' ,
10
- @headers = ' {"api-key":"<api-key>"}' ,
21
+ @credential = [https://<your-app-name>.openai.azure.com/openai/deployments/<deployment-id>] ,
11
22
@payload = @payload,
12
23
@response = @response output ;
13
24
drop table if exists #response;
You can’t perform that action at this time.
0 commit comments