Testing your LLM application through the promptfoo HTTP provider

Point promptfoo at the chat or agent API your users actually call, so evals and red team runs exercise your routing, auth, memory and guardrails, not a raw model. Validate the target before any full run.

On this page

Testing your LLM application through the promptfoo HTTP provider

Most products that use a model are not a bare model. They are an API around one: a chat endpoint with a system prompt, a RAG service that retrieves documents before it answers, or an agent that calls tools and applies policy. Testing the raw model misses everything in front of it, including the prompts, retrieval, tool permissions and guardrails that shape what users actually receive. The HTTP provider in promptfoo lets you point an eval or red team run at your own endpoint instead. It sends each test case to that endpoint as a request, reads the response back and grades it with the assertions you define. For custom applications, this is the supported method, and it tests the same path your users take.

Before you write a full suite, confirm the target works on its own. The promptfoo command line includes promptfoo validate target, which checks a configured target before a full eval runs. Use it to catch wrong URLs, missing authentication headers and request bodies your API rejects, since those failures otherwise show up as hundreds of errors across a run. Ask your engineering team which request shape the endpoint expects, which headers it requires in a test environment, and whether it returns the text, structured fields or citations that your assertions will need. Confirm these details against your own API documentation, because the request and response fields depend on how your application was built.

Plan for the parts of the setup that take the most judgment. The request template must match your API's schema, and the response parsing must extract the text that graders should see, which is where transformResponse comes in when the raw body is not the answer. Multi-turn tests need session handling so that follow-up messages reach the same conversation. Test traffic should also run against a non-production environment with test accounts and limits set aside for it, because red team probes can be unusual and high in volume. Document where the endpoint runs and who can read the results, since the prompts and responses in a run may include data from your systems.

What you need before the first HTTP target test

Before promptfoo sends a single request to your chat or agent API, the test machine or CI runner needs a supported runtime, a pinned package version, a safe endpoint to test against and working credentials. Each of the cards below is a gate that is cheap to check now and expensive to discover halfway through a run.

Node.js runtime version

promptfoo's npm release 0.124.1 requires Node.js 22.22.0 or newer. Check the version on every machine and CI image that will run the tests, not only the one where you first installed it. An older runtime often fails with unclear install or runtime errors, so confirm the version before you debug the target itself.

Pinned promptfoo version

Pin the package version in your project or CI configuration rather than installing whatever is latest. The HTTP provider's options and the promptfoo validate target behavior can change between releases, so a pinned version keeps results reproducible. Record the version alongside your eval results so later reruns use the same tool.

Reference release
0.124.1
promptfoo on npm

Non-production test environment

Point promptfoo at a staging or dedicated test deployment of your chat or agent API, not production. Red teaming sends adversarial prompts, and agents with tool access can take real actions. Ask the application owner which tools, data sources and downstream systems the test environment connects to, and confirm that writes are sandboxed or mocked.

Red teaming docs

Test account and credentials

Create a dedicated test user with the minimum role the scenarios need, and store its bearer token, API key or client secret in your secrets manager or CI variables. Never commit credentials to the config file. Confirm with the identity team how the token is issued and when it expires, because an expired token will look like a failing target.

Network reachability and egress

promptfoo runs on your machine or CI runner and talks directly to the endpoint, so the runner needs network routes and firewall or egress rules that allow outbound HTTP or HTTPS to the target host and any identity provider it calls for tokens. Test reachability from the exact runner, including proxies and VPN requirements, using a plain request before you rely on promptfoo.

Data handling approval

Because promptfoo evals run locally but send prompts and responses to your application and any grading model, confirm with your security and privacy owners where test traffic and results are stored, and which judge model receives the transcripts. Get that answer in writing before the first run that uses production-like data.

How to configure the HTTP provider, step by step

This sequence takes you from an empty config file to a verified promptfoo run against your own chat or agent API, with a check at each stage so a failure is traceable to one change.

  1. Create a minimal promptfoo config

    Start a promptfooconfig.yaml file in a new project folder with a single provider entry of type http and the URL of your chat endpoint. Keep it to one provider and one prompt at this stage so every later failure points to a single setting. Confirm the endpoint's method and path with the team that owns the API before you write the URL, because a wrong path is the most common first error. You are done when the file parses and lists one provider with the correct URL.

  2. Define the request template with the prompt variable

    Set the request body in the provider config so the prompt is inserted through the {{prompt}} variable, using the JSON shape your API expects (for example, a message field or a messages array). Copy a real request from your application's browser developer tools or API logs so the field names match exactly. Check that the body you intend to send is a valid JSON object once the variable is replaced. You are done when a single manual request sent with the same body returns a normal response from the API.

  3. Add headers and auth from environment variables

    Add the headers your API requires, such as Content-Type and any authorization header, and read secret values from environment variables rather than writing them into the YAML file. Store the value in your shell or CI secret store, and reference it in the config using the environment variable syntax promptfoo documents for the config file. Keep test accounts separate from production credentials. You are done when the config file contains no literal secret and the target still accepts the request when the variable is set.

  4. Extract the answer with transformResponse

    Add a transformResponse expression that reads the answer text from the JSON your API returns, for example pulling one field out of the response object. Without this step promptfoo grades the whole raw payload, which makes assertions unreliable. Test the expression against a saved response before running promptfoo, and handle the case where the field is missing so errors are visible. You are done when the output of one request, after transformation, is the plain answer text you expect to grade.

  5. Validate the target before a full eval

    Run promptfoo validate target from the project folder to check the configured target before any test cases are executed. The command confirms that promptfoo can reach and call the provider with your configuration, so a connection, header or template problem surfaces here rather than inside a long eval. Read the output for the exact error message and fix one setting at a time. You are done when validation reports the target as reachable and the test call returns text.

  6. Run one test case before the full suite

    Add a single test case with one prompt and one assertion, such as a check that the answer contains an expected phrase, then run the eval on that case only. Open the results view or output and confirm the request, the transformed response and the assertion result all match what you saw in your manual call. Only after that matches should you add the remaining test cases. You are done when one case passes for the reason you intended, and a deliberately wrong expected value fails.

  7. Confirm session handling before multi-turn tests

    If your API keeps conversation state, check how it passes a session identifier between requests before you write multi-turn tests. Confirm with the API owner whether the identifier comes from a response field or a header, and whether the server expires sessions. Run two sequential prompts in a test and verify the second answer depends on the first. You are done when a follow-up question returns an answer that uses earlier context, or you have documented that the API is stateless.

Request templates and raw HTTP requests

Choose between a body template and a raw HTTP request before you write the target configuration, because the choice sets how much work you will do every time your API changes. A body template is a short JSON or text body with a placeholder for the prompt, plus the URL and headers. It suits a chat endpoint with a stable request shape and few fields. A raw HTTP request is the full request copied from a browser developer tools panel or an API client, with method, path, headers, cookies and body exactly as the production client sends them. It suits agent APIs, endpoints with signed or session-bound headers, or any service where a hand-written template would drift from reality. The trade-off is maintenance and secrets. Templates are easy to review but can silently miss a field the server now requires. Raw requests are faithful but carry tokens, cookies and session identifiers that must not be committed to a repository or pasted into shared reports. Keep them in environment variables or your secrets store and confirm how your promptfoo version reads them before you rely on that pattern.

Test variables are injected into the request wherever the configuration places a variable reference, most often the prompt inside the body. Confirm the exact placeholder syntax and the list of supported injection points in the promptfoo command line and HTTP provider documentation for your installed version, because the wrong placeholder sends an empty or literal string and the run still appears to succeed. Keep the request as close as possible to what the production client sends: the same content type, the same field names and order where the server is strict, the same authentication header, and the same optional fields such as system instructions, tool settings or user identifiers. A test that sends a simplified request may pass against a path the real application never uses, and a red team scan built on that request will miss the injection routes that matter. Before a full run, compare one captured production request with one generated by promptfoo and check that the difference is only the test content.

Session handling for multi-turn tests

A stateless chat endpoint treats every request as complete. It receives the input for one turn and returns an answer, with no identifier that links it to earlier requests. For multi-turn tests against this kind of endpoint, the conversation history has to travel inside each request, so every turn carries the earlier user and assistant messages the application expects. Your request template is where that history is assembled. Confirm with the application team whether the endpoint expects a message array, a single string or a transcript, because the template must match that format.

  • Full history in every request: build the messages array from earlier turns so the endpoint sees the same context a user session would send.
  • Stable turn order: keep the turns of one conversation in a single ordered list so they are sent in the sequence you wrote them.
  • Assistant replies stored: if the endpoint expects prior assistant output, capture it from the response with transformResponse and place it into the next turn.
  • Input size limits: long histories enlarge every request, so check the endpoint's maximum input size before adding many turns.

Before trusting the suite, check that a deliberate reference to a fact from turn one is answered correctly in turn three.

Mapping your API fields to promptfoo variables and outputs

This table maps each part of your chat or agent API to the promptfoo setting that carries it, from the user message to the assertion inputs. Read it as a checklist: for each field your API uses, find the matching promptfoo element and confirm where its value comes from before the first eval runs.

API elementpromptfoo elementHow to set itWatch for
User messagePrompt variable in the request body templateReference the test variable in the body template so each test case fills the fieldConfirm the field name matches your API schema exactly, including nesting
Auth credentialRequest headerRead the token from an environment variable in the headers blockNever write the token value into the config file in plain text
Session or conversation IDCarried session value across turnsCapture the ID from a prior response and send it on the next request in the same testConfirm whether your API issues IDs per request or per conversation
Response textTransformed outputUse transformResponse to extract the field your API returns the answer inCheck the extracted value is the text your assertions will read, not the raw JSON
Tool calls or action metadataAssertion inputsExpose the tool name or arguments from the response so assertions can check themConfirm which fields your API returns in the response and which appear only in logs
Error or refusal statusOutput checked by assertionsMap HTTP status and error bodies to a readable output so failures are visibleErrors that return HTTP 200 can pass assertions unless you map them
Secrets and session tokensEnvironment variables onlyKeep API keys, bearer tokens and client secrets in your shell or CI secret storeDo not commit config files that contain credentials to version control

Security settings for testing a live application endpoint

Pointing promptfoo at a live chat or agent API means its requests carry credentials, reach real systems and, during red teaming, send deliberately hostile input. The cards below cover where secrets live, which account the tests use, which environment they hit, what reaches the reports and who owns the target.

Keep keys out of config files

Reference API keys and bearer tokens from environment variables or a secret store rather than writing them into the promptfoo YAML or the request template. Configuration files are usually committed to version control and shared between team members, so a token placed there is effectively published. In CI, inject the value from the pipeline's secret store at run time. Check that the config file in your repository contains only variable references.

Use a dedicated test account

Create a test user with the smallest set of roles that lets the tests reach the behavior under review. A red team run that impersonates a privileged user will exercise privileged tools, and a finding then tells you little about what an ordinary user could do. Give the account no production data, no payment or messaging permissions, and no ability to change its own roles. Ask the application owner to confirm the account can be disabled quickly if a run goes wrong.

Point tests at staging first

Run evals and red team scans against a staging deployment that mirrors production configuration, with synthetic or masked data. Confirm with the platform team what rate limits, quotas and cost ceilings apply to the test account, because a scan can send thousands of requests in a short period. Ask whether the staging model and tools have the same permissions as production, since that determines what a successful injection can reach.

Keep tokens out of reports

Eval outputs, red team reports and debug logs record request headers and response bodies, so a bearer token or session cookie can end up in a shared file or a CI artifact. Review which headers the target configuration sends and what the report stores, and redact authorization values before sharing results. Restrict who can read report artifacts, and confirm your CI platform does not print secret variables in console logs.

Scope adversarial traffic to your systems

Red team plugins and strategies send prompt injection, jailbreak and tool-misuse attempts that behave like an attacker's traffic. Run them only against systems your organization owns or has written permission to test, and tell the operations and security monitoring teams before the scan starts so alerts are expected rather than triggering incident response. Agree a stop condition in advance, such as an error rate or a downstream system showing unexpected writes.

Authentication layers are a separate topic

Bearer tokens, OAuth 2.0 flows, mutual TLS certificates and signed requests each need their own configuration in the HTTP provider. Those are covered on the sibling topic for authenticating promptfoo HTTP targets with OAuth 2.0 and mTLS, so this section only sets the handling rules that apply whatever method you use. Before you adopt a method, confirm with the application team which one fronts the endpoint in staging and in production.

Common HTTP target failures and how to fix them

This table lists the failures teams most often hit when pointing promptfoo at their own chat or agent API, with the likely cause and the fix for each. Read it in order when a validation run or first eval fails, since the early rows usually block the later ones.

FailureLikely causeFix
validate target fails on connection or DNSThe URL in the provider config is wrong for the machine running promptfoo, or the host resolves differently from the CLI environment (for example, a private hostname reachable only from inside a VPN or cluster).Run promptfoo validate target before a full eval, confirm the URL and port from the same machine and network that runs the CLI, and check proxy settings and DNS for that host.
401 or 403 from missing or expired auth headersThe headers block omits the bearer token or session cookie, or the token was copied from a browser session that has since expired.Store the token in an environment variable, reference it in the headers block, and confirm the test account still has access to the chat or agent route. Ask the application team which auth flow the production client uses.
Empty output because transformResponse points at the wrong fieldThe transformResponse expression reads a field name that does not exist in the actual JSON, often because the API nests the reply under a data or choices key or returns streamed chunks.Capture one raw response with a single test, inspect its structure, and update the path in transformResponse until the output is the assistant text. Check the output for an empty string before adding assertions.
Sessions that do not carry between turnsThe session identifier returned by the API is not extracted or not sent back on the next request, so each turn starts a new conversation on the server.Map the session ID from the response into the session config and reference it in the next request template. Verify with a two-turn test that the second answer uses context from the first.
Timeouts on slow agent responsesAgent workflows call tools, retrieval or other models before replying, so responses take longer than the default request limit allows.Raise the request timeout for this provider only, confirm the timeout on the API gateway and load balancer in front of the application, and reduce concurrency so slow calls do not queue behind each other.
Request bodies that differ from the production clientThe request template is written from API documentation rather than from the production client, so field names, headers, user identifiers or default parameters differ from what real users send.Capture a request from the production client in a non-production environment, copy its body and headers into the template, and compare responses so red team results reflect the real request shape.

Questions teams ask before testing their own API with promptfoo

Can our own team point promptfoo at our chat or agent API?

Yes, if the team has someone comfortable with HTTP requests, JSON templates and basic scripting. The work is mostly reading your API contract, writing a request template that matches it, and mapping the response field that holds the model's answer. Teams usually need one person who knows the endpoint well and one engineer who can read and edit a promptfoo configuration file. Authentication, multi-turn sessions and streaming responses add skill requirements, so check those against your team's experience before deciding to do it in-house.

What makes the effort to test an HTTP endpoint grow?

Effort grows with the number of endpoints and their request shapes, the authentication in front of them, and how much state the conversation carries. The main drivers are:

  • Number of endpoints and distinct request formats
  • Authentication complexity, such as bearer tokens, OAuth 2.0 or mutual TLS
  • Session behavior, meaning whether a conversation ID or cookie must persist across turns
  • Response shape, meaning how much parsing transformResponse needs before grading

A single endpoint with a simple JSON body and a token is a small job. Several agents with signed requests and streaming output is a larger one.

What does our organization need to provide for this work?

The work needs a test environment that is safe to send adversarial prompts to, test accounts with the same permissions as real users, current API documentation, and a named owner for the endpoint who can answer questions about its behavior. For red teaming, the owner should agree in writing which tools, data sources and downstream systems a test run may reach. Without a staging copy of the application, tests may generate real tickets, emails or transactions, so confirm this before any run starts.

How long does testing our API with promptfoo take?

The duration depends on scope: how many endpoints are covered, how complex their authentication and sessions are, and whether the team also wants red teaming alongside functional evals. No general duration applies, so ask for a timeline in a written plan that lists the endpoints, the test types and the client inputs each phase depends on. A plan should also say what happens if the environment or test accounts are not ready on the planned date.

Does promptfoo cost money to test our own endpoint?

The promptfoo Community edition is free and includes all LLM evaluation features, all model providers and integrations, and red teaming with 10k probes per month, according to the promptfoo pricing page. The HTTP provider is one of those integrations, so the tool itself does not add a license fee for this use. Costs that remain include your own compute, any model API charges for the judge or the application under test, and engineering time. Enterprise and On-Premise editions are priced on request and add team sharing, SSO and centralized monitoring.

Should we check the target before running a full promptfoo eval?

Yes. promptfoo includes a validate target command that checks a configured target before a full eval runs, so a wrong URL, header or response mapping shows up early. Use it after each change to the request template or transformResponse function. Validation confirms the request reaches the endpoint and the response is parsed, but it does not prove that your grading assertions are correct, so review a few raw outputs by hand before trusting results.

When is it worth bringing in a partner for promptfoo HTTP testing?

A partner is worth considering when the endpoint sits behind complex authentication, when many agents or APIs need coverage on a deadline, when the team needs evidence for a security review, or when no one internally can own the configuration over time. DeployOpen runs security testing of applications, APIs and AI agents and delivers findings with fixes and a retest. Scope, deliverables and timelines are agreed in writing before work starts, and ongoing testing is available as a retainer.

How a promptfoo test case reaches your API and returns for grading

The run starts with the promptfoo CLI on your test runner, which fills the request template with each test variable and sends it through the HTTP provider. The request crosses into your environment at the auth layer, reaches your chat or agent API, and then the model and tools behind it. The response travels back through transformResponse, which extracts the text that assertions grade. Check the boundary at the auth layer, and confirm with promptfoo validate target that the mapping works before a full eval.

Test variables travel through your API and return as text for grading.

How DeployOpen scopes and delivers HTTP target testing

DeployOpen plans, implements and tests promptfoo inside infrastructure you control, so the HTTP target that represents your chat or agent API is wired up, validated and documented before any test suite depends on it. Engagements are fixed-scope, with the target, deliverables and timeline agreed in writing before work starts.

How we scope

  • Inventory the chat or agent API under test, its request shape, response fields and authentication method
  • Agree in writing which endpoints, sessions and test accounts the promptfoo HTTP target will cover
  • Confirm where promptfoo will run, whether locally, in CI or on a self-hosted server, before work starts
  • Fixed-scope agreement sets deliverables and timeline; a quote follows from the written scope

How we build

  • Build the HTTP provider configuration, request template and transformResponse logic against your real API contract
  • Validate the target with promptfoo validate target before any full eval or red team run is scheduled
  • Configure session handling for multi-turn tests and confirm test sessions stay isolated from production data
  • Test the target for prompt injection, tool permission and data exposure paths your scope names

How we hand over

  • Deliver the working configuration files, environment variable map and a runbook for reruns
  • Document each request template, response mapping and known limitation so your team can maintain them
  • Walk your engineers through validation output, failure triage and how to add new test cases
  • Provide a findings report with fixes and a retest, where the scope includes security testing

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after handover
  • Retainers can cover updates when your chat or agent API changes its request or response format
  • Confirm with DeployOpen during scoping how support hours, response expectations and escalation are defined
  • Revisit the target configuration when promptfoo releases change provider behavior you depend on

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.