Portkey AI integration
Portkey is an AI observability suite that includes prompt management capabilities.
To reference prompts in Portkey:
-
Set the
PORTKEY_API_KEYenvironment variable. -
Use the
portkey://prefix for your prompts, followed by the Portkey prompt ID. For example:prompts:
- 'portkey://pp-test-promp-669f48'
providers:
- openai:gpt-5
tests:
- vars:
topic: ...
Variables from your promptfoo test cases will be automatically plugged into the Portkey prompt as variables. The resulting prompt will be rendered and returned to promptfoo, and used as the prompt for the test case.
Note that promptfoo does not follow the temperature, model, and other parameters set in Portkey. You must set them in the providers configuration yourself.
Using Portkey gateway
The Portkey AI gateway is directly supported by promptfoo. See also:
- Portkey's documentation on integrating promptfoo
- Building trust in AI with Portkey and Promptfoo - comprehensive guide with advanced use cases, red-teaming workflows, and production deployment strategies
Example:
providers:
id: portkey:gpt-5
config:
portkeyProvider: openai
More complex portkey configurations are also supported.
providers:
id: portkey:gpt-5
config:
# Can alternatively set environment variable, e.g. PORTKEY_API_KEY
portkeyApiKey: xxx
# Other configuration options
portkeyVirtualKey: xxx
portkeyMetadata:
team: xxx
portkeyConfig: xxx
portkeyProvider: xxx
portkeyApiBaseUrl: xxx