Virtual Keys
Create Virtual Key
API Reference
Virtual Keys
Prompts
- POSTCreate Prompt
- GETList Prompts
- GETRetrieve Prompt
- PUTUpdate Prompt
- DELDelete Prompt
- PUTPublish Prompt
- GETList Prompt Versions
- GETRetrieve Prompt Version
- PUTUpdate Prompt Version
- Prompt Partials
- Prompt Labels
- Prompt Collections
API Keys
Analytics [BETA]
- Summary
- Groups Paginated Data
- Graphs - Time Series Data
User Invites
Workspaces
Workspace Members
Audit Logs
OpenAPI
Create Virtual Key
POST
/
virtual-keys
from portkey_ai import Portkey
# Initialize the Portkey client
portkey = Portkey(
api_key="PORTKEY_API_KEY",
)
# Add a new virtual key
new_virtual_key = portkey.virtual_keys.create(
name="openaiVKey",
provider="openai",
key="PROVIDER_API_KEY"
)
print(new_virtual_key)
{
"success": true,
"data": {
"slug": "<string>"
}
}
Azure OpenAI
Create virtual key to access your Azure OpenAI models or deployments, and manage all auth in one place.
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)
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)
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 Bedrock
Create virtual key to access your AWS Bedrock models or deployments, and manage all auth in one place.
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)
Vertex AI
Create virtual key to access any models available or hosted on Vertex AI. Docs →
Learn More About Virtual Keys
Securely store your provider auth in Portkey vault and democratize and streamline access to Gen AI.
Authorizations
Body
application/json
Response
200
application/json
Successful response
The response is of type object
.
Was this page helpful?
from portkey_ai import Portkey
# Initialize the Portkey client
portkey = Portkey(
api_key="PORTKEY_API_KEY",
)
# Add a new virtual key
new_virtual_key = portkey.virtual_keys.create(
name="openaiVKey",
provider="openai",
key="PROVIDER_API_KEY"
)
print(new_virtual_key)
{
"success": true,
"data": {
"slug": "<string>"
}
}