Skip to main content
Promptbeat includes a Go web service for downstream systems that need to call Promptbeat as an API instead of running the CLI directly. The service exposes seed expansion, batch task management, and dataset risk mapping over REST. Because the API service and CLI share the same core engine, results are equivalent regardless of which interface you use.

Features


Endpoints

POST /api/v1/attack/preview

Use preview for small-batch seed expansion where you need a low-latency response. The endpoint runs generation synchronously and returns results in the same HTTP response — ideal for iterating on seed quality or debugging a new scenario.
array
required
List of seed objects to expand. Each seed must include at minimum a text field containing the raw attack template.
integer
Number of probes to generate per seed. Keep this small (1–5) when using preview to avoid long synchronous wait times.
integer
Hard cap on total generated outputs across all seeds in this request.
string
Provider string for the generator LLM, e.g. openai:openai/gpt-5.5. Overrides the service-level default set via environment variable.
array
List of Promptfoo plugin IDs to apply during generation.
array
List of strategy names to use when expanding seeds.
Example request body:

POST /api/v1/attack/task/create

Use task/create when your seed count, expansionRatio, or maxOutputs is large enough that generation should run asynchronously. The endpoint immediately returns a taskId you can poll. This prevents HTTP timeouts on large expansion jobs and lets you integrate Promptbeat generation into async pipelines.
array
required
List of seed objects to expand. Accepts the same structure as preview.
integer
Number of probes to generate per seed. No practical upper limit when running asynchronously.
integer
Hard cap on total generated outputs across all seeds in this task.
string
Provider string for the generator LLM. Falls back to PROMPTBEAT_GENERATOR_PROVIDER if not supplied.
string
Optional webhook URL. The service POSTs results to this URL when the task completes.
Example request body:
Example response:

GET /api/v1/attack/task/{taskId}

Poll this endpoint to check task status and retrieve results once the task completes. The response includes a status field (queued, running, done, or failed) and, when done, the full expansion results.
Example response (task complete):

Running the service locally

The API service ships as a Docker image. Use the two make targets to build and start it:
The service listens on port 8080 by default. Place runtime environment variables in api/.env.docker before running make docker-run.

Environment variables


Smoke test

Run the bundled smoke test against a local container to verify the service is healthy:
Override BASE_URL to smoke-test a deployed service:
The API service and CLI share the same core Promptbeat engine. A generation job submitted via the API produces identical output to the same job run with ./bin/promptbeat generate.