Python
Default
from portkey_ai import Portkey# Initialize the Portkey clientportkey = Portkey( api_key="PORTKEY_API_KEY",)# Add a new virtual keynew_virtual_key = portkey.virtual_keys.create( name="openaiVKey", provider="openai", key="PROVIDER_API_KEY")print(new_virtual_key)
{ "success": true, "data": { "slug": "<string>" } }
Default Auth
from portkey_ai import Portkey client = Portkey( api_key="<api_key>" ) virtual_key = client.virtual_keys.create( name="Azure-Virtual-Default", provider="azure-openai", note="Azure Note", key="<api_key>", resourceName="<resource_name>", deploymentConfig=[ { "apiVersion": "2024-08-01-preview", "deploymentName": "DeploymentName", "is_default": True, }, { "apiVersion": "2024-08-01-preview", "deploymentName": "DeploymentNam2e", "is_default": False, }, ], ) print(virtual_key)
Azure Entra ID
from portkey_ai import Portkey client = Portkey( api_key="<api_key>" ) virtual_key = client.virtual_keys.create( name="Azure-Virtual-entra", provider="azure-openai", note="azure entra", resourceName="<resource_name>", deploymentConfig=[ { "deploymentName": "<deployment_name>", "is_default": True, "apiVersion": "2024-08-01-preview", } ], azureAuthMode="entra", azureEntraClientId="<client_id>", azureEntraClientSecret="<client_secret>", azureEntraTenantId="<tenantId>", ) print(virtual_key)
Azure Managed Identity
from portkey_ai import Portkey client = Portkey( api_key="<api_key>", ) virtual_key = client.virtual_keys.create( name="Azure-Virtual-entra", provider="azure-openai", note="azure entra", resourceName="<resource_name>", deploymentConfig=[ { "deploymentName": "<deployment_name>", "is_default": True, "apiVersion": "2024-08-01-preview", } ], azureAuthMode="managed", azureManagedClientId="<client-id>" # optional ) print(virtual_key)
AWS Assumed Role
from portkey_ai import Portkey client = Portkey( api_key="<api_key>", ) virtual_key = client.virtual_keys.create( name="bedrock-assumed", provider="bedrock", note="bedrock", awsRegion="<region>", awsAuthType="assumedRole", awsRoleArn="arn:aws:iam::<account_id>:role/<role_name>", awsExternalId="<external_id>", ) print(virtual_key)
Successful response
The response is of type object.
object
Was this page helpful?