Testing through AI gateways: Cloudflare, Envoy, F5 and MLflow

Point promptfoo at the AI gateway your production traffic already uses, so evals and red team runs hit the same routing, caching and policies. Each gateway needs its own provider setup and checks.

On this page

Testing through AI gateways with promptfoo: why route tests through production's gateway

If production LLM traffic already passes through an AI gateway, tests that call the model directly are measuring a different system. The gateway adds routing rules, response caching, rate limits, credential handling and policy checks, and each of these can change what a user actually receives. A promptfoo suite that bypasses the gateway can pass while the production path fails, or fail for reasons that never reach users. The practical decision is to point promptfoo at the same gateway endpoint that production uses, so the eval and red team runs exercise the same routing and policies.

promptfoo has documented providers for four gateways: Cloudflare AI Gateway, Envoy AI Gateway, F5 AI Gateway and MLflow AI Gateway. Envoy AI Gateway is reached through its OpenAI-compatible endpoint, so the test configuration looks like any other OpenAI-compatible target. F5 AI Gateway reads the F5_API_KEY environment variable by default, which keeps the key out of the config file. MLflow AI Gateway is built into the MLflow tracking server from MLflow 3.0, so the endpoint and the MLflow version in your environment determine the setup. Confirm the exact provider identifiers and configuration keys for each gateway in promptfoo's provider documentation before you copy them into a suite.

Because promptfoo runs on your machine and talks directly to the gateway endpoint, the test traffic leaves your workstation or CI runner and travels through the gateway like production traffic does. Plan for three things before the first run: which gateway credentials the test job uses, whether test traffic is counted against the same quotas and budgets as production, and how gateway logs will separate test requests from real users. Ask the gateway owner whether caching could hide regressions, since a cached response may pass a check that a fresh model call would fail. Settle these points first, because they decide whether the gateway results can be trusted as evidence.

Which gateway provider fits which traffic path

Production traffic often passes through an AI gateway before it reaches a model, so the gateway is where routing, caching and policy decisions happen. promptfoo ships a provider for each of the four gateways below, and each one reaches a different traffic path. Pick the provider that matches the gateway your production traffic already uses, then confirm which features that gateway enforces in your own deployment.

Cloudflare AI Gateway

Cloudflare AI Gateway sits in front of model providers as a managed proxy, and promptfoo has a provider for it. Use it when production calls already go through Cloudflare, so test runs hit the same routing and caching layer as real users. Confirm which caching, rate limiting and logging settings apply to test traffic, and whether eval volume should use a separate gateway configuration so it does not skew production analytics or quotas. Check the provider docs for the account and gateway identifiers you need.

Cloudflare gateway docs

Envoy AI Gateway

Envoy AI Gateway is an open-source proxy that promptfoo reaches through its OpenAI-compatible endpoint. It fits organizations that run Envoy in their own clusters and route model traffic through it. Because you control the proxy, you can run tests against the same route definitions, auth filters and upstream selection that production uses. Confirm which routes, backends and header policies your gateway version applies, and make sure test credentials are scoped to the routes they need.

Envoy provider docs

F5 AI Gateway

The F5 AI Gateway provider reads the F5_API_KEY environment variable by default, so credentials can stay out of configuration files. Choose it when your organization already runs F5 for traffic and security controls and wants evaluations to pass through those policies. Confirm which policies, guardrails and logging the gateway applies to requests from test runs, and whether CI jobs should use a dedicated key with its own audit trail. Store the key in your secrets manager, not in the repository.

F5 provider docs

MLflow AI Gateway

MLflow AI Gateway is built into the MLflow tracking server from MLflow 3.0, so teams already running MLflow can test through the same server that manages their models and experiments. This suits organizations that want gateway configuration, tracing and evaluation records in one place. Confirm which gateway endpoints are enabled on your tracking server, who can create or change endpoints, and how test traffic is separated from production endpoints in the same server.

MLflow gateway docs

How to configure promptfoo for each gateway, step by step

This sequence takes a team from a dedicated test credential on the gateway to a confirmed request in gateway logs, so the test traffic follows the same routing and policies as production. Each step closes with a check that tells you whether to move on.

  1. Create a test-only key or route

    Ask the gateway owner to create a credential or route used only by promptfoo, separate from production keys and applications. Scope it to the models and policies you intend to test, and record which gateway, route name or endpoint it points to. The step is done when the owner confirms the key exists, is limited to the intended routes, and is not shared with production services. Confirm the exact key scoping options and route setup with your gateway's documentation, since they vary by product.

  2. Store credentials as environment variables

    Put the gateway key in an environment variable on the machine or CI runner that runs promptfoo, rather than writing it into the config file. For F5 AI Gateway, promptfoo reads F5_API_KEY by default. Other gateways may need their own variables, so check the provider page for each. The check is that running a short command that prints only the variable's length or a masked value shows a value is present, and that the config file contains no secret.

  3. Set the provider ID and base URL in config

    In your promptfooconfig.yaml, set the provider for the gateway you are testing and point it at the gateway endpoint, using the provider ID and base URL from the matching promptfoo provider page for Cloudflare AI Gateway, Envoy AI Gateway, F5 AI Gateway or MLflow AI Gateway. Reference the environment variable for the key instead of the value. The check is that promptfoo parses the config without errors when you run its validation or a dry run.

  4. Run one known prompt through the gateway

    Create a minimal test with a single prompt whose expected answer is obvious, such as a fixed arithmetic question, and run promptfoo against that one provider. This isolates connection and authentication problems from evaluation logic. The step is done when the run returns a successful response with the expected content and no authentication or routing error. If it fails, check the base URL path, the route name and the key scope before changing the test.

  5. Confirm the request appears in gateway logs

    Open the gateway's request logs or analytics and find the entry for the single prompt you just sent. Check that it arrived on the test credential or route, that the model and endpoint match your config, and that the timestamp matches your run. This proves the traffic actually passed through the gateway rather than reaching the model directly. If no entry appears, the provider is bypassing the gateway, and the base URL needs review.

  6. Verify caching and policy behavior

    Run the same known prompt a second time with identical settings. If the gateway has caching enabled, the second response should come from the cache, which the gateway log or response metadata should show. Then send a prompt that your gateway policy is meant to block, and confirm the gateway returns the expected block or rewrite. These checks show that tests exercise the routing, caching and policies production traffic uses. Confirm which caching and policy features your gateway version supports before writing these checks.

  7. Record the configuration for reuse

    Save the working config, the variable names (never the values), the gateway route name and the log location in your team's repository or runbook. Note the promptfoo version you tested with, since the npm release 0.124.1 requires Node.js 22.22.0 or newer and provider behavior can change between versions. The step is done when a teammate can rerun the single-prompt check from the runbook alone and reach the same gateway log entry.

How gateway routes, keys and models map to promptfoo providers

This table maps the concepts you already use in each AI gateway (routes, accounts, API keys, upstream models and caching policies) to the promptfoo provider settings that call them. Read each row as a question to answer in your own gateway before you write the config. The main takeaway is that the gateway's own settings, not promptfoo, decide what a test response looks like, so the test expectations must match the gateway configuration under test.

Conceptpromptfoo mappingWhat your team must confirm in its gateway
Gateway account or routeProvider ID for the gateway in the promptfoo provider documentation (Cloudflare AI Gateway, Envoy AI Gateway, F5 AI Gateway or MLflow AI Gateway)Which account, gateway, endpoint or route the test traffic should reach, and that it is separate from production routes
Gateway API keyEnvironment variable named in the provider docs (F5 reads F5_API_KEY by default); keep keys out of committed config filesWhether the key is scoped to test use, its rotation owner, and whether gateway logs will record test prompts under it
Upstream model nameThe model field in the provider configuration, passed through to the gatewayThe exact model name the gateway forwards upstream, including any alias that the gateway rewrites
Envoy OpenAI-compatible endpointEnvoy AI Gateway is reached through its OpenAI-compatible endpoint, so the base URL points at the Envoy routeThe route path, the listener address and which backends the route exposes to the test client
MLflow tracking server gatewayMLflow AI Gateway is built into the MLflow tracking server from MLflow 3.0, so the target is the tracking server gateway endpointThe MLflow version running on the server (3.0 or later) and the gateway endpoint name configured on it
Gateway cachingExpect cached responses to repeat exactly; promptfoo's own cache is separate from gateway cachingWhether the gateway caches responses, the cache key and TTL, and whether tests need cache hits or misses to be deliberate
Gateway guardrails or policiesTest expectations should state whether a block, redaction or rate limit is the passing result for an attack caseWhich policies run on the test route, their order relative to upstream calls, and whether they match production policy
Rate limits and quotasTests may fail with throttling responses that look like model errors, so set concurrency to match the gateway limitThe per-key or per-route rate limit and quota for test traffic, and who is alerted when it is exhausted

Keeping gateway credentials and test traffic separate from production

Testing through a gateway sends real credentials and sometimes sensitive data through shared infrastructure. The cards below cover the controls that keep test traffic apart from production traffic, and the checks to run before the first red team scan reaches a gateway.

Use test-only gateway keys

Create a separate gateway key or virtual credential for promptfoo runs instead of reusing the key your production application holds. Give it its own name, spending limit and rate limit so a runaway eval or a red team scan cannot exhaust production quota. For F5_API_KEY, confirm with your F5 administrator which key scope and environment the variable resolves to on each machine. Rotate the test key on a schedule you set, and revoke it when the engagement ends. Never let a test key carry production permissions.

F5 provider docs

Scope gateway routes to test use

Point promptfoo only at the routes, models and policies that the test is meant to cover. In Envoy AI Gateway, for example, a dedicated route or backend for test traffic keeps evaluation requests from mixing with live routing rules. Confirm with the gateway owner which routes accept your test key and which upstream model accounts they bill to. A narrow route scope also makes it clear which provider a failing test actually reached.

Store secrets outside config files

Keep gateway keys out of promptfooconfig.yaml and out of the repository. Reference them through environment variables or your secrets manager, and inject them into CI as masked, protected variables scoped to the jobs that need them. Check that the config file you commit contains no inline tokens, and that CI logs do not echo the environment. Set the variables per environment so a developer laptop never holds the production key.

Keep sensitive test data out of logs

Red team prompts often contain simulated personal data, account numbers or secrets that look real. Before running scans through a gateway, decide which request and response fields the gateway logs, how long it keeps them and who can read them. Where logging is on by default, prefer synthetic test data over copies of production records. Review promptfoo output files and CI artifacts too, since reports can repeat the prompts they tested.

Separate test logs from production logs

Send gateway logs for test traffic to a separate project, workspace or index so that test prompts and responses never appear in production dashboards or analytics. Label test requests with metadata or a tag where the gateway supports it, and confirm that retention rules for test logs match the purpose of the test rather than the production policy. Ask the gateway owner who can query each log store, since shared admin roles often see both.

Check gateway policies before red teaming

Guardrails, content filters and rate limits at the gateway can block red team probes, which produces misleading results: a refusal may come from the gateway rather than the model. Ask the gateway owner which policies apply to test keys, and run a small probe set first to see what the gateway blocks. Record which blocks came from the gateway and which came from the model, so findings reflect the system you intend to assess. Remember that promptfoo runs on your own machine and talks directly to the endpoint you configure, so the traffic path is the one your gateway policies govern.

Why results through a gateway can differ from direct model calls

A gateway changes the path between promptfoo and the model, so a pass rate measured through Cloudflare AI Gateway, Envoy AI Gateway, F5 AI Gateway or MLflow AI Gateway may not match the same suite run directly against the provider. The first cause to check is caching. A gateway can return a stored response for a repeated prompt, so a test may pass on an answer produced by an earlier model version or an earlier prompt. That hides regressions, because promptfoo grades the cached text as if it were a fresh generation. Before trusting a gateway run, confirm in each gateway's settings whether response caching is enabled for the route, how long entries live, and whether the cache key includes the model, system prompt and parameters your suite changes. Turn caching off for the comparison runs, or record the cache status in the results.

Rate limits and retries are the second cause. A gateway may throttle requests, queue them or retry failed calls on its own, and each of these changes what promptfoo sees. A test that times out at the gateway can be graded as a failure, while a retried call can succeed after a delay and look like a slow but correct response. Pass rates can therefore shift with concurrency settings in promptfoo, not because the model behaved differently. Check the gateway's rate limit and retry configuration, and compare the promptfoo concurrency and timeout values with those limits before you read a difference as a model finding.

The third cause is guardrail and policy blocks. When a gateway or a policy in front of it rejects a request, the response is often a refusal message, an HTTP error or an empty body. Unless the provider configuration maps these responses to a clear status, promptfoo may grade a blocked request as a refusal and count it as a safe pass, or as a broken response and count it as a failure. Either way, the score no longer measures the model. Decide in advance how each block should be recorded, and keep blocks visible in the report. When the team needs to isolate the cause of a difference, run the same suite directly against the model and through the gateway, with caching, limits and policies set the same way where possible, then compare the two result sets case by case.

Common gateway failures when running promptfoo and their fixes

This table lists the failures teams most often hit when pointing promptfoo at Cloudflare, Envoy, F5 or MLflow gateways, with the likely cause and the fix for each. Read it before a first run, and again when an eval fails or passes for no clear reason. The main takeaway is that many gateway problems look like model problems, so check the route, the key and the gateway's own logs before changing prompts or assertions.

FailureLikely causeFix
Authentication error (401 or 403)The API key is missing, empty or belongs to a different gateway or account than the endpoint. For F5, promptfoo reads F5_API_KEY by default, so a key set under another name is ignored.Confirm the variable name the provider reads, export the key in the same shell or CI job that runs promptfoo, and test the endpoint with a single request before running the full suite.
Base URL points at the wrong routeThe configured URL targets the gateway root, a management path or a different provider route than the one that serves model traffic. Cloudflare and Envoy routes differ by account and configuration.Copy the exact endpoint for the route production uses from the gateway configuration, then confirm the path in the provider docs before adjusting the URL.
Envoy endpoint not reachableThe Envoy AI Gateway proxy is not exposed on the address promptfoo runs from, the port-forward has stopped, or the cluster network blocks the runner.Check the Envoy service and listener from the machine running promptfoo, restore port-forwarding or the ingress route, and confirm the OpenAI-compatible endpoint responds before starting an eval.
MLflow gateway missing or too oldThe MLflow tracking server is below MLflow 3.0, or it runs without the AI Gateway feature enabled, so the gateway endpoint does not exist.Confirm the tracking server version is MLflow 3.0 or later and that the gateway is configured on that server. Then check the gateway endpoint name in promptfoo matches the one defined in MLflow.
Unexpected cache hits make evals passA gateway cache returns stored responses for repeated prompts, so a changed prompt or model may still show the old answer and the assertions pass on stale output.Record whether caching is on for the test route, disable or bypass it for regression runs, and compare cache status in the gateway logs against the promptfoo results.
Gateway policy block read as a model refusalA guardrail, rate limit or content policy in the gateway returns an error or a fixed refusal message, and promptfoo grades that text like a model answer.Check the gateway logs for the request, separate policy responses from model output in assertions, and decide with the security owner whether blocked attacks count as passes.
Results differ from productionThe test route uses different routing rules, a test key with different limits, or a different model alias than production traffic.Compare the gateway route, model alias and policy settings between the test and production configurations, and confirm with the gateway owner which settings the tests are meant to share.

Questions teams ask before testing through an AI gateway

Can our team test through an AI gateway in-house, or do we need a partner?

Yes, most teams with platform engineering and security skills can do it in-house, because promptfoo points at a gateway the same way it points at a model provider. The Cloudflare, Envoy, F5 and MLflow providers are documented in the promptfoo provider docs, and the work is mostly configuration, credentials and test design. The harder parts are usually outside promptfoo: getting a test key with the right route and budget, confirming which policies the gateway applies, and keeping test traffic out of production logs. If your team already runs the gateway, owns its routes and can review its policies, in-house work is realistic. If no one owns the gateway configuration, a partner can help define scope first. Ask any partner for a written scope before work starts.

What drives the effort of testing through an AI gateway?

Effort grows with the number of gateways, the number of routes or model aliases behind each one, and how each gateway authenticates requests. Each combination of gateway, route and credential is a separate target to configure and verify. Network segmentation adds work when the gateway sits in a private subnet that the test runner must reach, because access paths, proxies and firewall rules need review. Policy differences matter too: caching, rate limits, guardrails and fallback routing can change results, so each one needs a test case that shows its effect. Before estimating, list your gateways, routes, auth methods and network boundaries. That inventory is the input any quote should be based on.

Is promptfoo Community enough for testing through a gateway?

For most gateway testing, yes. The promptfoo Community edition is free under the MIT license and includes all LLM evaluation features, all model providers and integrations, and red teaming with 10k probes per month. The gateway providers are part of that set, so you do not need a paid edition to point promptfoo at Cloudflare AI Gateway, Envoy AI Gateway, F5 AI Gateway or MLflow AI Gateway. Community support is the main difference. Enterprise adds team sharing, SSO, role-based access and continuous monitoring, which matter when several teams share results or when your security function needs central reporting. Check the current promptfoo pricing page before deciding, since edition contents can change.

What changes when the gateway is self-hosted in our network?

The promptfoo configuration stays largely the same, but the network and the trust model change. The test runner must reach the gateway's internal address, which may require a VPN, a bastion or a runner inside the same network. Certificates issued by an internal certificate authority need to be trusted by the runner, and the gateway's own authentication, such as virtual keys or service tokens, must be issued to the test identity. Logs now sit in your infrastructure, so decide how test prompts are stored, retained and separated from production traffic. Also confirm the gateway version and its policies in your environment, since self-hosted configuration is owned by your team. Keep the promptfoo run and the gateway in the same change-control process as other security tests.

Which gateway authentication model should we plan for?

Plan for each gateway's own credential model rather than assuming one pattern. The promptfoo F5 provider reads the F5_API_KEY environment variable by default, so store that key in your CI secret store or a vault, not in config files. For Envoy AI Gateway, promptfoo reaches the proxy through its OpenAI-compatible endpoint, so authentication depends on how your Envoy deployment is configured. MLflow AI Gateway is built into the MLflow tracking server from MLflow 3.0, so access follows the tracking server's setup. Cloudflare AI Gateway uses your account and gateway identifiers. Confirm each method against the provider docs and your gateway's own settings, and use a dedicated test credential with a limited budget and scope.

Will gateway caching or policies hide the weaknesses we want to test?

They can, which is why you should test with and without the gateway's policies enabled. Caching can return stored responses, so repeated eval runs may look more stable than the model really is, and guardrails or filters can block attacks before they reach the model. Both results are useful, but they answer different questions. Run one suite through the gateway to match production routing, and run another against the model directly to see the underlying behavior. Record which policies were active for each run. Without that record, a clean red team report may reflect the gateway rather than the application.

When is it worth bringing in a partner for gateway testing?

Bring in a partner when the work spans several gateways, sits in a segmented network, or needs evidence that an assessor will review. DeployOpen plans, implements, tests and documents self-hosted platforms inside the client's own infrastructure, and runs security testing that covers AI systems. Most engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts, and a quote follows from that scope. A partner is also useful when the team lacks time to maintain test suites after the first run. Ask for the written scope, the list of gateways and routes covered, the evidence delivered and how retesting after gateway upgrades is handled. DeployOpen does not issue audit reports or certifications.

How a promptfoo test request reaches the model through the gateway

The flow starts with the promptfoo CLI running on a developer machine or CI runner, which sends each test prompt to the gateway's endpoint rather than directly to the model provider. The gateway applies the routing, caching and policies that production traffic also passes through, then forwards the request to the upstream model. The response returns along the same path, and promptfoo grades it locally. Check that the gateway's logs and policies apply to test traffic and that the credential the CLI uses is a test credential.

Test traffic crosses the trust boundary through the gateway before reaching the model.

How DeployOpen scopes and delivers promptfoo gateway testing

DeployOpen approaches testing through AI gateways as a planned engagement: we map the gateway path production traffic takes, then set up promptfoo to run through that same path. Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.

How we scope

  • Map which gateway production traffic uses: Cloudflare AI Gateway, Envoy AI Gateway, F5 AI Gateway or MLflow AI Gateway.
  • Confirm routing, caching and policy rules that tests must reproduce, and which of them the gateway owner controls.
  • Agree in writing which models, applications and environments are in scope, and which credentials and test accounts are needed.

How we build

  • Configure promptfoo providers for your gateway, keeping credentials in environment variables rather than config files.
  • Verify that test requests pass through the gateway and that its logs, caching and policies behave as production expects.
  • Build eval suites and red team configurations that run through the gateway, with separate keys or routes for test traffic.

How we hand over

  • Deliver the promptfoo configuration, provider settings and run instructions in your repository, with a record of decisions made.
  • Document how to confirm gateway-side behavior, including which logs and policy events to check after each run.
  • Walk your platform and security teams through results, open findings and the retest plan before the engagement closes.

How we support

  • Offer ongoing support, upgrades and continuous testing as a retainer when gateway configurations or promptfoo versions change.
  • Retest after gateway policy changes, model additions or promptfoo upgrades, so evidence stays current with production.
  • Plan hosting of any promptfoo server in your infrastructure, since the self-hosted app is not recommended for production use as shipped.

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.