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>"
}
}{
"success": false,
"data": {
"message": "Unauthorised Request"
}
}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>"
}
}{
"success": false,
"data": {
"message": "Unauthorised Request"
}
}Deprecated. Use the Integrations API to store provider credentials and the Providers API to create AI Providers in your workspace. Existing virtual keys continue to work — no code changes needed.
Azure OpenAI
Create virtual key to access your Azure OpenAI models or deployments, and manage all auth in one place.Default Auth
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)
import Portkey from 'portkey-ai';
const portkey = new Portkey({
apiKey: 'PORTKEY_API_KEY'
});
async function main() {
const key = await client.virtualKeys.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,
}
]
});
console.log(key);
}
main();
Azure Entra ID
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)
import Portkey from 'portkey-ai';
const portkey = new Portkey({
apiKey: 'PORTKEY_API_KEY'
});
async function main() {
const key = await client.virtualKeys.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>"
});
console.log(key);
}
main();
Azure Managed Identity
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)
import Portkey from 'portkey-ai';
const portkey = new Portkey({
apiKey: 'PORTKEY_API_KEY'
});
async function main() {
const key = await client.virtualKeys.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
});
console.log(key);
}
main();
AWS Bedrock
Create virtual key to access your AWS Bedrock models or deployments, and manage all auth in one place.AWS Assumed Role
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)
import Portkey from 'portkey-ai';
const portkey = new Portkey({
apiKey: 'PORTKEY_API_KEY'
});
async function main() {
const key = await client.virtualKeys.create({
name: "bedrock-assumed",
provider: "bedrock",
note: "bedrock",
awsRegion: "<region>",
awsAuthType: "assumedRole",
awsRoleArn: "arn:aws:iam::<account_id>:role/<role_name>",
awsExternalId: "<external_id>"
});
console.log(key);
}
main();
Vertex AI
Create virtual key to access any models available or hosted on Vertex AI. Docs →Model Catalog
Manage AI providers and models centrally with budget limits, rate limits, and model provisioning.
Portkey is now PRISMA AIRS AI Gateway. See it in action.
Contact Us
Authorizations
Body
application/json
Available options:
openai, azure-openai, ai21, anthropic, anyscale, azure-openai, bedrock, cohere, deepinfra, fireworks-ai, google, groq, hugging-face, jina, lingyi, mistral-ai, monsterapi, moonshot, nomic, novita-ai, open-ai, openrouter, palm, perplexity-ai, predibase, reka-ai, segmind, stability-ai, together-ai, vertex-ai, workers-ai, zhipu optional, needed when using organisation admin API keys
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Example:
{
"credit_limit": 10,
"periodic_reset": "monthly",
"alert_threshold": 8
}
Show child attributes
Show child attributes
Dynamically resolve secrets from secret references at runtime. Valid target_field values are "key" or "model_config." (e.g. "model_config.awsSecretAccessKey"). Each target_field must be unique. When "key" is mapped, the key field becomes optional.
Show child attributes
Show child attributes
Last modified on August 3, 2026
Was this page helpful?
⌘I

