import requests url = "https://api.portkey.ai/v1/virtual-keys" payload = { "provider": "azure-openai", "key": "openai-test", "name": "Key 1 Azure Open AI", "note": "description", "apiVersion": "a", "deploymentName": "b", "resourceName": "c" } headers = { "x-portkey-api-key": "****", "Content-Type": "application/json" } response = requests.request("POST", url, json=payload, headers=headers) print(response.text) >>>{ "success": false, "data": { "message": "You do not have enough permissions to execute this request", "errorCode": "AB03", "request_id": "27c675d5-c322-4f7e-89cc-064c26c913f9" } }
create/update/delete
on virtual-keys
admin
type userdeployments: []
curl --request POST \ --url https://api.portkey.ai/v1/virtual-keys \ --header 'Content-Type: application/json' \ --header 'x-portkey-api-key: iHu65wqZ+H09086' \ --data '{ "provider": "azure-openai", "key": "1c4bba6669094e2fba84bad323240984", "name": "eastus-openai", "note": "Account: my-openai, Region: eastus", "apiVersion": "2024-10-01-preview", "deployments": [ { "apiVersion": "2024-08-01-preview", "deploymentName": "gpt-4o", "resourceName": "openai-eastus" } ] }'
curl --request POST \ --url https://api.portkey.ai/v1/virtual-keys \ --header 'content-type: application/json' \ --header 'x-portkey-api-key: <api_key>' \ --data '{ "provider": "azure-openai", "key": "key", "name": "eastus-openai", "note": "Account: my-openai, Region: eastus", "resourceName": "resourceName", "deploymentConfig": [ { "apiVersion": "2024-08-01-preview", "deploymentName": "<deploymentName>", "is_default": true } ] }'
cURL
.deploymentConfig
array should contain a config with is_default: true
as that will be treated as default config for virtual even multiple deployments are available in single resourcename. if the config is not a default config it should contain a alias
key. Please take a look at the following example config for more context."deploymentConfig": [ { "apiVersion": "2024-08-01-preview", "deploymentName": "<deploymentName>", "is_default": true }, { "apiVersion": "2024-08-01-preview", "deploymentName": "<deploymentName>", "is_default": false, "alias": "second-modal-optional" }, ]
1
default config passed i.e is_default: true
should be applied to only 1 deployment config only.curl --request PUT \ --url https://api.portkey.ai/v1/virtual-keys/dev-eastus-unit-aa74b9 \ --header 'Content-Type: application/json' \ --header 'x-portkey-api-key: i2wBueZ+K1FQSf9yCxKuP6J93El1' \ --data '{ "key": "4531f90749c4d019dc05ebfb1d4v79c"}'
curl --request PUT \ --url https://api.portkey.ai/v1/virtual-keys/dev-eastus-unit-aa74b9 \ --header 'Content-Type: application/json' \ --header 'x-portkey-api-key: i2wBueZ+K1FQSf9yCxKuP6J93El1' \ --data '{ "key": "4531f90749c4d019dc05ebfb1d4v79c"}'
{"success":false,"data":{"message":"Invalid request. Please check and try again.","errorCode":"AB01","request_id":"753c0eb8-f44a-4b46-ad09-84a2fca974a6"}}
curl --request PUT \ --url https://api.portkey.ai/v1/virtual-keys/dev-eastus-unit-aa74b9 \ --header 'content-type: application/json' \ --header 'x-portkey-api-key: i2wBueZ+xxyyzzP6J93El1' \ --data '{ "name": "eastus-unityopenai", "provider": "azure-openai", "key": "xxx", "note": "Account: unityopenai, Region: eastus", "resourceName": "unityopenai", "deploymentConfig": [ { "apiVersion": "2024-10-01-preview", "deploymentName": "unityprod", "is_default": true, "alias": "dev-eastus-unityprod" }, { "apiVersion": "2024-10-01-preview", "deploymentName": "unityprod2", "is_default": false, "alias": "dev-eastus-unityprod2" } ] }' >>> {"success":false,"data":{"message":"Something went wrong. Please try again."}}%
PUT
it is failing for me.cURL
should work not.500
, this is because either payload is incorrect or one of the keys are incorrect i.e resourceName
or deploymentName
or apiVersion
. This is because we try to fetch the model name from azure before creating, if can't fetch model (can be because above keys might be wrong and azure did throw an error) we throw the error. Anyhow things should be good now, please try it and let us know if still there's an issue.