Imagine usecases where you want to redact PII, remove some requests and redact responses when making a bulk batch inference call to providers like OpenAI, Azure OpenAI, Bedrock, Vertex AI, etc. Portkey supports running guardrails on provider batch requests. You pass guardrails through a config, and Portkey applies them asynchronously — pre-processing inputs before sending to the provider, and post-processing outputs after the provider completes.Documentation Index
Fetch the complete documentation index at: https://docs.portkey.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
How It Works
Upload a batch input file
Upload a JSONL file in OpenAI chat completions format to Portkey.Each line in the file should be a valid chat completions request. Download an example JSONL file.The response returns a Portkey file ID (
pk_file_*):Create a config with guardrails
Guardrails are the only supported way to pass guardrail checks to a provider batch request. Define them in a Portkey config here:Save this config in the Portkey dashboard and note the config ID (e.g.,
pc-sync-g-1009a3).Create a provider batch
Reference your uploaded file ID and config when creating the batch:The response contains a Portkey batch ID (
pk_batch_*) and the initial guardrail results in hook_results:Poll for batch status
Poll the batch to track progress. Once input guardrails are applied, the If your config includes
input_file_id is replaced with a new processed file. Use include_provider_details=true to see full upstream details:output_guardrails, the batch enters an intermediate processing_post_request_guardrails state after the upstream provider finishes. Once complete, output_file_id reflects the final guardrail-processed output file.Batch Lifecycle with Guardrails
| State | Description |
|---|---|
validating | Batch created; input guardrails being evaluated |
in_progress | Input guardrails passed; provider is processing requests |
processing_post_request_guardrails | Provider finished; output guardrails being evaluated |
completed | All guardrails applied; output file ready |
The
input_file_id in the batch response is updated after input guardrails
process the file — the new ID points to the transformed input sent to the
upstream provider.
