I’ve created a create a blueprint connector so I can use our Azure OpenAI instance with the ML features, but I’m running into an issue when I try executing the _predict
endpoint to test the connector.
I’m getting the following error:
Error from remote service: {"error":{"code":"401","message":"Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource."}}
The error message is clear, but I know the API key I’m passing is valid and I can successfully make API calls from the CLI, so I suspect something is wrong with my connector configuration and it’s incorrect building the url
endpoint.
Here’s what my connector looks like:
POST /_plugins/_ml/connectors/_create
{
"name": "My test connector"
, "description": "My description."
, "version": "0.1"
, "protocol": "http"
, "parameters": {
"resource_name": "my-resource-name"
, "deployment_name": "my-deployment-name"
, "model": "my-model-name"
, "api_version": "2024-10-21"
, "temperature": 0.0
}
, "credential": {
"openAI_key": "my-api-key"
}
, "actions": [
{
"action_type": "predict"
, "method": "POST"
, "url": "https://${parameters.resource_name}.openai.azure.com/openai/deployments/${parameters.deployment_name}/chat/completions?api-version=${parameters.api_version}"
, "headers": {
"content-type": "application/json"
, "api-key": "${credential.openAI_key}"
}
, "request_body": '{ "messages": ${parameters.messages}, "temperature": ${parameters.temperature} }'
}
]
}
When I check the opensearch log file, all I get is a line like:
[2024-11-25T19:22:07,895][ERROR][o.o.m.e.a.r.MLSdkAsyncHttpResponseHandler] [giva-dev] Remote server returned error code: 401
How can I debug the actual HTTP call so I can see what’s going on?
I’ve combed through the documentation but I’m not finding anything.
Thanks!
-Dan