How to authenticate requests to the Portkey AI Gateway, including provider API keys and the Portkey hosted service.
The gateway itself does not require authentication by default when self-hosted. Authentication is handled at the provider level — you pass the target provider’s credentials with each request.For the Portkey hosted service, you additionally need a Portkey API key.
Pass the provider’s API key using the standard Authorization header, paired with the x-portkey-provider header to tell the gateway which provider to route to.
POST /v1/chat/completions HTTP/1.1Host: localhost:8787Authorization: Bearer <PROVIDER_API_KEY>x-portkey-provider: openaiContent-Type: application/json
The value of Authorization is forwarded to the target provider as-is.
When using the Portkey Cloud, pass your Portkey API key using the x-portkey-api-key header instead of managing provider credentials directly. Portkey’s virtual key system handles credential management on the backend.
POST /v1/chat/completions HTTP/1.1Host: api.portkey.aix-portkey-api-key: <PORTKEY_API_KEY>x-portkey-provider: openaiContent-Type: application/json
Virtual keys let you store provider API keys in Portkey’s secure vault and reference them by name. See the Portkey documentation for virtual key setup.