Configuration reference
The Traffic Policy configuration reference for this action.Supported phases
on_event_stream_message
Type
sse-find-replace
Configuration fields
Behavior
When this action executes, it processes each SSE message as it streams through ngrok, applying replacement rules to the specified fields.SSE message structure
Server-Sent Events consist of messages with fields likedata, event, id, and retry.
This action currently supports modifying the data and retry fields.
Pattern matching
Thefrom field accepts RE2 regular expressions.
All matches within the specified field are replaced, not just the first occurrence.
Streaming behavior
Unlike the request/response body find & replace actions, this action processes messages in real-time as they stream through. Each SSE message is processed independently.Capture groups
You can use capture groups in your pattern and reference them in the replacement:CEL expressions
Thefield, from, and to parameters all support CEL interpolation for dynamic values:
from field, the resulting string must be a valid regular expression.
Non-terminating action
This is a Non-terminating action. It does not return a response, and will allow Traffic Policy processing to continue to the next Action in the chain. All Cloud Endpoint Traffic Policies must end with a terminating action. This requirement does not apply to Agent Endpoints.Examples
Redacting sensitive data from streaming AI responses
When using streaming AI responses (like OpenAI’s chat completions withstream: true),
you can redact sensitive information in real-time.
Example Traffic Policy document
Modifying streaming AI output format
Transform streaming content as it’s delivered to clients:Filtering profanity from streaming responses
Remove or replace inappropriate content from AI responses in real-time:Modifying retry behavior
Change the retry interval in SSE streams:Action result variables
The following variables are made available for use in subsequent expressions and CEL interpolations after the action has run. Variable values will only apply to the last action execution, results are not concatenated.Related actions
- Request Body Find & Replace - Modify request bodies
- Response Body Find & Replace - Modify response bodies