Header requirements and options for the Portkey API
Portkey Authentication Header | Required | For Portkey auth |
Provider Authentication Headers OR Cloud-Specific Headers | Required | For provider auth |
Additional Portkey Headers | Optional | To pass config , metadata , trace id , cache refresh etc. |
Custom Headers | Optional | To forward any other headers directly |
PORTKEY_API_KEY
Example
openai
, anthropic
, vertex-ai
)."Bearer $TOKEN"
.x-api-key
or api-key
, you can pass the token with the Authorization
header directly and Portkey will convert it into the provider-specific format.Example
Example
JSON object
or a config ID
that can also contain gateway configuration settings, and provider details.Example
openai
."Bearer $TOKEN"
.x-api-key
or api-key
, you can pass the token with the Authorization
header directly and Portkey will convert it into the provider-specific format.Example
Example
_user
to associate requests with specific users. (Docs)Example
true
or false
See the caching documentation for more information. (Docs)Example
Example
Example
Example
X-My-Custom-Header
, it should be sent as X_My_Custom_Header
in the SDKX-My-Custom-Header
, it should be sent as xMyCustomHeader
in the SDKAzure
, Google
, AWS
)Azure OpenAI
, Google Vertex AI
, or AWS Bedrock
x-portkey-azure-resource-name
, x-portkey-azure-deployment-id
, x-portkey-azure-api-version
, Authorization
, x-portkey-azure-model-name
x-portkey-vertex-project-id
, x-portkey-vertex-region
, X-Vertex-AI-LLM-Request-Type
x-portkey-aws-session-token
, x-portkey-aws-secret-access-key
, x-portkey-aws-region
, x-portkey-aws-session-token
Parameter | Type | Key |
---|---|---|
API Key Your Portkey account’s API Key. | stringrequired | apiKey |
Virtual Key The virtual key created from Portkey’s vault for a specific provider | string | virtualKey |
Config The slug or config object to use | stringobject | config |
Provider The AI provider to use for your calls. (supported providers). | string | provider |
Base URL You can edit the URL of the gateway to use. Needed if you’re self-hosting the AI gateway | string | baseURL |
Trace ID An ID you can pass to refer to 1 or more requests later on. Generated automatically for every request, if not sent. | string | traceID |
Metadata Any metadata to attach to the requests. These can be filtered later on in the analytics and log dashboards Can contain _prompt , _user , _organisation , or _environment that are special metadata types in Portkey. You can also send any other keys as part of this object. | object | metadata |
Cache Force Refresh Force refresh the cache for your request by making a new call and storing that value. | boolean | cacheForceRefresh |
Cache Namespace Partition your cache based on custom strings, ignoring metadata and other headers. | string | cacheNamespace |
Custom Host Route to locally or privately hosted model by configuring the API URL with custom host | string | customHost |
Forward Headers Forward sensitive headers directly to your model’s API without any processing from Portkey. | array of string | forwardHeaders |
Azure OpenAI Headers Configuration headers for Azure OpenAI that you can send separately | string | azureResourceName azureDeploymentId azureApiVersion azureModelName |
Google Vertex AI Headers Configuration headers for Vertex AI that you can send separately | string | vertexProjectId vertexRegion |
AWS Bedrock Headers Configuration headers for Bedrock that you can send separately | string | awsAccessKeyId awsSecretAccessKey awsRegion awsSessionToken |