promptfoo with Portkey prompt management

Test prompts stored in Portkey by referencing them with the portkey:// prefix in a promptfoo config and setting PORTKEY_API_KEY. This page covers the setup, its limits, and how it differs from routing model calls through a gateway.

On this page

How promptfoo tests prompts managed in Portkey

When prompts live in Portkey and your team wants promptfoo to evaluate them, you reference each prompt in the promptfoo config with the portkey:// prefix followed by the Portkey prompt ID, and promptfoo reads the PORTKEY_API_KEY environment variable to fetch that prompt. The prompt text stays in Portkey as the source of record, while the test cases, assertions and pass criteria stay in your promptfoo config under version control. Before the first run, confirm which Portkey workspace and API key the pipeline will use, because the key determines which prompts the run can read.

promptfoo runs on your machine and calls the models itself. Portkey supplies only the prompt text. That split matters for data flow: test inputs and model responses travel from the machine running promptfoo directly to the providers defined in your config, not through Portkey. Portkey's role in this setup is to return the stored prompt when promptfoo asks for it. Ask the security and platform owners to confirm that this is the path your approved data handling policy expects, and check which model provider credentials the run also needs, since those are separate from PORTKEY_API_KEY.

This topic is not the same as routing model traffic through a Portkey gateway. A gateway sits in the request path, so every production call passes through it, and the question there is how requests are logged, routed and governed. Here, Portkey is a prompt store that promptfoo reads at evaluation time, and nothing in your application changes. Confirm the exact prompt ID format and key scope in the promptfoo Portkey integration docs before you wire the config into CI, and decide early who may rotate the key and how it is stored.

What you need before connecting promptfoo to Portkey

Connecting promptfoo to Portkey prompts takes four pieces: the promptfoo CLI on a supported Node.js runtime, a Portkey account that holds the prompt under test, a Portkey API key, and credentials for the models each eval calls. The network path between the machine running the eval and Portkey's API decides whether the first run succeeds, so check it before writing the config.

Node.js runtime for the promptfoo CLI

The current npm release, 0.124.1, requires Node.js 22.22.0 or newer. Install the CLI on the machine or CI runner that will run the eval, then confirm the version with node --version before anything else. An older runtime can fail during install or at startup, which looks like a promptfoo problem but is an environment problem. Pin the Node.js version in your pipeline image so every run uses the same runtime.

promptfoo on npm

Portkey account and the prompt under test

The eval reads a prompt that already exists in Portkey, referenced by its prompt ID. Confirm that the account owning the API key can see that prompt, and that the prompt's current version is the one you intend to test. Ask the prompt owner which version the team treats as production, because a later edit in Portkey changes what the next eval run tests.

Portkey integration docs

Portkey API key with prompt access

promptfoo reads the key from the PORTKEY_API_KEY environment variable, so it should be set in the shell or CI secret store rather than written into the config file. Use a key scoped to the workspace that holds the prompts, and record who owns it and when it rotates. A key that can read production prompts also exposes them to every machine that runs the eval, so limit where it is stored.

Provider credentials for the evaluated models

Portkey supplies the prompt, but the model calls made during the eval still need credentials for the providers behind the prompt. Confirm which models the prompt targets, then check that each provider key is available to the runner and permitted for the eval volume you plan. Keep these keys separate from the Portkey key so that a leak of one does not expose the other.

Egress path to Portkey's API

The machine running promptfoo must reach Portkey's API over HTTPS, and the model providers must be reachable from the same machine. Corporate proxies, egress allowlists and inspection appliances can block these calls or break TLS, and the failure often appears as an authentication error. Ask the platform team which proxy settings apply to the runner and whether the Portkey and provider domains are on the allowlist before the first run.

promptfoo introduction

Where the eval runs and who reviews the results

promptfoo runs evals on the machine where the command executes and calls the models directly, so the runner, its logs and its cached outputs hold test data. Decide whether that runner is a developer laptop, a CI agent or a controlled host, and confirm that its disk and log retention meet your data handling rules. Name the reviewers who will read failing results before the first pipeline gate depends on them.

Configure the portkey:// reference and API key

This sequence takes you from a clean install to a first passing eval that loads a prompt managed in Portkey. Each step ends with a check, so you know the reference, the key and the assertions work before you rely on the results.

  1. Install promptfoo and confirm the runtime

    Install the promptfoo CLI on the machine or runner that will execute the evals. The npm release 0.124.1 requires Node.js 22.22.0 or newer, so check your Node.js version first. Run the promptfoo version command to confirm the CLI starts. The step is done when the command prints a version number without errors.

  2. Identify the Portkey prompt ID

    In your Portkey workspace, locate the prompt you want to test and copy its prompt ID. Your platform or prompt owner should confirm which prompt and version the team treats as the source of truth, since promptfoo reads whatever the ID points to. Store the ID in your notes or a team ticket. The step is done when you have one ID that matches the prompt in the Portkey interface.

  3. Set PORTKEY_API_KEY in the environment

    Export the Portkey API key as the PORTKEY_API_KEY environment variable in the shell, CI secret store or runner configuration. Keep the key out of promptfooconfig.yaml so the config can be committed to version control. Confirm with your security team where the key is issued, who holds it and how it is rotated. The step is done when a fresh shell can read the variable and the config file contains no key.

  4. Reference the prompt with portkey://

    In the promptfoo config, add the prompt to the prompts list using the portkey:// prefix followed by the Portkey prompt ID, for example portkey://<prompt-id>. Pair it with a provider entry for the model the prompt will run against. Use the official Portkey integration page to confirm the exact syntax for your promptfoo version. The step is done when the config file validates and lists the Portkey reference without a placeholder.

  5. Add test cases and assertions

    Add a small set of tests with variables that the prompt expects, plus assertions that define a pass. Start with simple checks such as required content or output format, since they are deterministic and easy to review. Agree with the prompt owner on what a correct output looks like before you write the assertions. The step is done when every test has at least one assertion and the file reads clearly to someone who did not write it.

  6. Run a single test case first

    Run promptfoo eval against one test case to confirm the Portkey reference resolves and the model returns output. Check the terminal output or web viewer to confirm the prompt text came from Portkey, not a local copy. If the run fails, first check that PORTKEY_API_KEY is visible to the process and that the prompt ID matches. The step is done when one case returns output and its assertion result is recorded.

  7. Run the full eval and review results

    Expand the test set to the full list and run the eval again. Open the results view to review each assertion, compare outputs and confirm that failures reflect real prompt problems rather than configuration errors. Note the promptfoo and Node.js versions used so the run can be reproduced later. The step is done when the full run completes and the team agrees the results reflect the managed prompt.

Why referencing prompts differs from routing calls through a gateway

Referencing a Portkey prompt and routing model calls through the Portkey gateway are two separate integration points, and confusing them leads to wrong assumptions about what is tested and what is logged. When promptfoo resolves a portkey:// reference, it reads the prompt content stored in Portkey, using the prompt ID and the PORTKEY_API_KEY setting, so the prompt text becomes the input to your eval. The model calls that the eval then makes can still go directly to a provider, so the gateway's routing, request logs and spend records are not involved unless you configure the model calls to pass through Portkey as well. Before you rely on either behavior, confirm in the promptfoo docs: Portkey AI integration which provider settings apply to your setup, because the two concerns are configured in different places in the config.

A practical check is to run one eval, then compare the Portkey dashboard against your provider's usage records. If the requests appear in Portkey, the gateway is in the request path. If only the prompt was fetched, the gateway is acting as a prompt source only. Write this result into your test plan so reviewers know which system produced which evidence.

Teams make three common choices here. They may reference Portkey prompts and call models directly, which keeps prompt management in one place while leaving request routing unchanged. They may route calls through Portkey and test the same prompts, which lets the eval exercise the production path and its logging. Or they may use a different gateway for routing and keep Portkey only for prompts. Each choice changes who owns access controls, log retention and key rotation, so decide the ownership with your security and platform teams before the first run.

Mapping Portkey prompt IDs, keys and config fields to promptfoo

This table maps each Portkey-related element in a promptfoo setup to where it lives, whether it is secret, and which system owns it. Read it before wiring a config, so that prompt text stays in Portkey while assertions and model credentials stay under your control. The main takeaway is that the prompt ID is a reference, not the prompt itself, and the API key is the only Portkey credential promptfoo needs.

ElementWhat it isWhere it livesSecret or owned by
portkey:// referencePrefix plus the Portkey prompt ID, used as the prompt entry in the promptfoo configpromptfoo config file, under the prompts sectionNot secret. Points to a prompt owned in Portkey
Portkey prompt IDIdentifier of the managed prompt that promptfoo fetchesInside the portkey:// reference in the configNot secret. Owned by the Portkey prompt
PORTKEY_API_KEYCredential that lets promptfoo read prompts from PortkeyEnvironment variable on the machine or CI runner running promptfooSecret. Owned by your Portkey account, kept out of the config file
Prompt textThe instructions and template sent to the model under testStored and versioned in Portkey, not copied into the configOwned by the Portkey prompt
Provider credentialsKeys for each model entry under testEnvironment variables or provider settings read by promptfooSecret. Owned by your model provider account
Model entries under testProviders listed in the config that run the promptpromptfoo config file, under the providers sectionNot secret. Owned by your eval configuration
Assertions and test casesExpected outputs, graders and test data that judge resultspromptfoo config file or referenced test filesOwned by your team in your repository, not by Portkey

Protecting the Portkey key and prompt content

Testing prompts from Portkey means one credential reaches into your prompt library, and every eval run produces outputs that may echo that prompt text. The cards below cover how to handle the key, who can use it, and where the resulting data lives.

Keep the key out of source and logs

Set PORTKEY_API_KEY as an environment variable or as a secret in your CI system, never as a value inside promptfooconfig.yaml or a committed .env file. Check that pipeline steps do not echo environment variables and that job logs are not shared more widely than the repository. A key that appears in a log or pull request comment should be treated as exposed and rotated immediately.

Portkey integration docs

Scope the key to the prompt workspace

Confirm in Portkey how API keys are scoped and which workspace or prompts a given key can read. Use a key that can read only the prompts this evaluation needs, and do not reuse a key that also manages production gateway traffic or billing. Ask your Portkey administrator to confirm the exact permission model for your plan, since the scoping options depend on your account setup.

Rotate the key on a schedule

Agree a rotation procedure before the first pipeline runs: who creates the replacement key, where it is stored, how the pipeline secret is updated, and how the old key is revoked. Rotate immediately after staff changes or any suspected leak. Confirm with Portkey how keys are revoked and whether revocation takes effect immediately for in-flight runs.

Limit who can read the secret

Restrict the PORTKEY_API_KEY secret to the protected branches and the jobs that run prompt evaluations. Forked pull requests and unreviewed branches should not receive it. Review which developers can view or edit CI secrets, since anyone with that access can read the key outside the pipeline.

Know where eval traffic runs

promptfoo runs locally, so evals run on the machine or CI runner that executes them and talk directly with the model providers. Prompts fetched from Portkey, test inputs and model outputs stay on that runner unless your own pipeline uploads them. Confirm the runner's network path and that its storage and logs fit your data handling policy.

promptfoo introduction

Handle results as sensitive

Eval and red team results can contain full prompt text, including system instructions and business logic, along with model responses that may echo it. Decide where result files are stored, how long artifacts are kept, and who can download them from CI. Apply the same retention and access rules you use for the prompt library itself.

Common failures when promptfoo cannot load Portkey prompts

This table lists the failures most likely to stop promptfoo from loading a prompt managed in Portkey, with the likely cause, the fix and what to check in the Portkey dashboard and local environment. Work down the rows in order, since a missing key or wrong Node.js version blocks every other check. Treat the prompt version row as the one that changes results rather than fails loudly.

FailureLikely causeFix and what to check
Authentication error when loading the promptPORTKEY_API_KEY is unset, empty or copied from the wrong Portkey workspaceConfirm the variable is exported in the shell or CI job that runs promptfoo. In the Portkey dashboard, check that the key belongs to the workspace that owns the prompt, and generate a new key if the old one was revoked.
Prompt not found after the portkey:// prefixThe prompt ID is mistyped, or the reference points at a prompt in another workspaceCopy the prompt ID from the Portkey prompt page and compare it character by character with the config. Confirm the key in use has access to the workspace where that prompt is stored.
Node.js version too oldThe local or CI runner uses a Node.js release below the version promptfoo requiresRun node --version on the same machine or runner that executes promptfoo. Upgrade to Node.js 22.22.0 or newer, which the promptfoo npm release 0.124.1 requires, then reinstall dependencies.
Results change after a prompt updateThe prompt was edited in Portkey and the reference now resolves to a different version than the last baselineRecord which prompt version each eval ran against. In the Portkey dashboard, compare the version history with your last passing run, and pin the version your config expects before comparing results.
Model entries fail after the prompt loadsProvider credentials for the models listed in the config are missing from the environmentConfirm each provider's API key variable is set in the same environment as PORTKEY_API_KEY. Check that the model identifiers in the config match models your provider account can access.
Environment differs between laptop and CIThe variable is set in a shell profile locally but not defined as a secret in the pipelineCompare the variable names on both sides. Define PORTKEY_API_KEY as a masked pipeline secret, and confirm the CI job passes it to the promptfoo step.

Questions teams ask before connecting promptfoo to Portkey

Is promptfoo free to use with Portkey prompts?

Yes, promptfoo is licensed under the MIT license, and the promptfoo Community edition is free and includes all LLM evaluation features and all model providers and integrations. Referencing a Portkey prompt with the portkey:// prefix is a configuration choice inside that same open-source CLI, so it does not require a paid edition. Costs that do arise come from your Portkey account, the model provider API usage each eval triggers, and any outside help you choose to buy. Confirm with Portkey which plan your account needs for the prompt management features you plan to use.

What cost and effort drive an outside implementation?

An implementation is mostly labor, and the main drivers are the number of prompts, the number of providers under test, and how many environments and CI pipelines need the same config. Other drivers include how your prompt inventory is organized in Portkey, whether you need variable mapping across prompt versions, and how results must be reported to reviewers. Ask any partner for a quote built from a written scope that lists these items, the deliverables, and what is recurring (such as maintenance of configs) versus one-time (initial wiring and documentation).

How long does setup take for a Portkey and promptfoo connection?

Duration depends mainly on how many prompts and providers you want covered and how clean your existing prompt inventory is. A small set of prompts referenced from one config is a short task, while dozens of prompts across several providers, with pass criteria agreed per prompt, takes longer. We do not quote a fixed timeline here. Ask for a schedule tied to the agreed prompt list, with milestones for the first passing eval and for CI integration.

What does our team need to provide before the work starts?

Plan to supply the following before setup begins:

  • A Portkey account with access to the prompts in scope, and the prompt IDs you want to reference
  • A PORTKEY_API_KEY value stored in your secrets manager, with a clear owner and rotation process
  • API keys for each model provider the evals will call
  • A written inventory of prompts, expected outputs, and who approves changes
  • Access for the implementer to your CI runners or the environment where evals run

Missing any of these usually delays the first run more than the configuration itself.

Can one internal engineer set this up without outside help?

Often yes, for a small and well-defined set of prompts. The promptfoo config is a YAML file, the Portkey prompt is referenced by its ID with the portkey:// prefix, and the API key is read from the environment, so a developer familiar with promptfoo can build a working first eval. The harder parts are assertion design, secrets handling in CI, and keeping configs maintainable as prompts change. Decide based on whether someone can own the eval suite over time, not only the first run.

How does a gateway choice change the work?

Referencing Portkey prompts with portkey:// is about where prompt text comes from. Routing model calls through an AI gateway is about where requests travel at runtime. These are separate decisions. If your production traffic already passes through a gateway such as LiteLLM, you still need to decide whether promptfoo calls the model providers directly or through that gateway, because this changes the keys, logging, and rate limits involved. Document that choice before building configs, since switching it later means revisiting every provider entry.

Does this setup keep test data inside our environment?

promptfoo runs locally and calls the models directly, so eval inputs and outputs go to the providers you configure and to Portkey when prompts are fetched. Whether that meets your data handling rules depends on your Portkey and provider agreements, not on promptfoo alone. Confirm data residency and retention with each vendor, and review what is logged in Portkey and in your eval reports before running production-like data.

How the promptfoo run, Portkey prompt store and model providers connect

The run starts on a developer machine or CI runner, where promptfoo reads the portkey:// prompt reference and uses the PORTKEY_API_KEY from the runner's secret store to fetch the prompt from Portkey. promptfoo then sends the rendered prompt directly to the model provider under test, and its assertions grade the output locally. Check that the key is injected only into the runner, that the provider credentials stay on the runner, and that the optional gateway path is used only where you have decided it belongs.

Prompt retrieval and model calls follow separate paths from the runner.

Keeping prompt tests current as Portkey prompts change

The main risk with prompts managed in Portkey is that a prompt edit changes what your tests check without anyone touching the promptfoo config. Treat each Portkey prompt change as a trigger for a fresh eval run, and run the same suite against the previous and new prompt so a regression is visible as a before and after comparison. Confirm with Portkey whether a portkey:// reference resolves to the latest published version of a prompt or to a fixed version, and whether that behavior differs between prompt IDs and versions. Ask how historical versions remain retrievable so you can rerun an old eval later.

Where the version is not pinned by the reference, record it yourself. Store the Portkey prompt version, the model identifier, the promptfoo version and the date with each eval output, so a failing run can be traced to a prompt edit, a model change or a tool upgrade. When a failure appears after a prompt edit, review the prompt diff first, then rerun the same cases against the prior version. When the same prompt fails with no edit, the model or provider side is the more likely cause and should be investigated separately.

Keep the promptfoo version current by reading the promptfoo releases notes before each upgrade, since assertion behavior, grading defaults and Portkey integration details can change between releases. Upgrade in a branch, rerun your baseline suite, and compare results before you adopt the new version for gating. Confirm the Node.js requirement for the release you pick, because the current npm release requires Node.js 22.22.0 or newer.

How DeployOpen scopes and delivers this integration

DeployOpen approaches promptfoo with Portkey prompt management as a fixed-scope piece of work inside your own environment. We agree what the promptfoo config will reference, how the PORTKEY_API_KEY is supplied and where the evals run, then build, document and hand over the setup so your team can run it.

How we scope

  • Inventory the Portkey prompts to be tested and the prompt IDs that promptfoo configs will reference with the portkey:// prefix
  • Agree where PORTKEY_API_KEY is stored, who owns the key and which environments may read it
  • Confirm which providers and models the evals call, and whether a gateway sits in the request path
  • Record the scope, deliverables and timeline in writing before any build work starts

How we build

  • Write promptfoo configs that pull managed prompts by ID and pair them with your test cases and assertions
  • Wire the API key through environment variables or your secret store, never hard-coded in config files
  • Run baseline evals against current Portkey prompt versions to confirm the references resolve as expected
  • Test the setup for leaked keys, unexpected prompt changes and misreferenced prompt IDs before handover

How we hand over

  • Document each portkey:// reference, the prompt owner, the environment variable and the run commands
  • Explain how to tell apart a failing prompt change from a broken prompt reference or expired key
  • Walk your engineers through running evals locally and in your pipeline, with the results and follow-up steps
  • Deliver the configs, runbook and secret handling notes in your repository and infrastructure

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after handover
  • Review the setup when promptfoo or Portkey releases change how prompt references or authentication behave
  • Confirm with your Portkey administrators and promptfoo documentation before relying on any feature not described in the supplied integration notes
  • Keep the scope written and revisit it in writing when new prompts, providers or pipelines are added

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.