[ 
https://issues.apache.org/jira/browse/IMPALA-13131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17854592#comment-17854592
 ] 

ASF subversion and git services commented on IMPALA-13131:
----------------------------------------------------------

Commit 3668a9517c4d8097591ed3b6fa672bf87faa77f6 in impala's branch 
refs/heads/master from Abhishek Rawat
[ https://gitbox.apache.org/repos/asf?p=impala.git;h=3668a9517 ]

IMPALA-13131: Azure OpenAI API expects 'api-key' instead of 'Authorization' in 
the request header

Updated the POST request when communicating with Azure Open AI
endpoint. The header now includes 'api-key: <api-key>' instead of
'Authorization: Bearer <api-key>'.

Also, removed 'model' as a required param for the Azure Open AI api
call. This is mainly because the endpoint contains deployment which
is basically already mapped to a model.

Testing:
- Updated existing unit test as per the Azure API reference
- Manually tested builtin 'ai_generate_text' using an Azure Open AI
deployment.

Change-Id: If9cc07940ce355d511bcf0ee615ff31042d13eb5
Reviewed-on: http://gerrit.cloudera.org:8080/21493
Reviewed-by: Impala Public Jenkins <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>


> Azure OpenAI API expects 'api-key' instead of 'Authorization' in the request 
> header
> -----------------------------------------------------------------------------------
>
>                 Key: IMPALA-13131
>                 URL: https://issues.apache.org/jira/browse/IMPALA-13131
>             Project: IMPALA
>          Issue Type: Bug
>            Reporter: Abhishek Rawat
>            Assignee: Abhishek Rawat
>            Priority: Major
>
> As per the [API 
> reference|https://learn.microsoft.com/en-us/azure/ai-services/openai/reference],
>  the header expects API key as follows:
>  
> {code:java}
> curl 
> https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/completions?api-version=2024-02-01\
>   -H "Content-Type: application/json" \
>   -H "api-key: YOUR_API_KEY" \             <<<<<<< API Key
>   -d "{
>   \"prompt\": \"Once upon a time\",
>   \"max_tokens\": 5
> }" {code}
> Impala supports API Key as follows:
>  
>  
> {code:java}
> curl 
> https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/completions?api-version=2024-02-01\
>   -H "Content-Type: application/json" \
>   -H "Authorization: Bearer YOUR_API_KEY" \   <<<<<<<< API Key
>   -d "{
>   \"prompt\": \"Once upon a time\",
>   \"max_tokens\": 5
> }"{code}
> This causes ai functions calling Azure OpenAI endpoint to fail with 401 error:
> {code:java}
> { "statusCode": 401, "message": "Unauthorized. Access token is missing, 
> invalid, audience is incorrect (https://cognitiveservices.azure.com), or have 
> expired." } {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to