responseProvider can read the request body, call another
host, fetch the origin, and construct the response returned to the client.
This integration evaluates requests to the AI routes matched by the EdgeWorker.
It does not inspect origin responses, direct calls to model providers, or
employee use of third-party AI services.
Integration capabilities
Before you start
Start with the policy in Observe mode. Findings appear in Activity without
affecting traffic. Switch to Enforce after reviewing the results. See
Policies.
1. Map the TrustGuard endpoint under your property
An EdgeWorkershttpRequest sub-request reaches only hostnames your Akamai
property serves. A direct call to {TRUSTGUARD_URL} fails with a 400, so map
the TrustGuard host as an origin on your property.
In Property Manager, route a path on the property to the TrustGuard host as
an origin:
/trustguard/v1/evaluate, not the absolute
URL. If you change the prefix, update both the property mapping and the worker.
2. Write the responseProvider
BecauseresponseProvider constructs the response, the worker must fetch the
origin and construct the client response with createResponse, including for allowed
requests. The allow path therefore makes two sub-requests. Both count toward the
wall-time limit described in
step 4.
request.getHeader() returns an array, which is why header
values use ?.[0]. Without it, the worker sends an array where
POST /v1/evaluate expects a string.
The sample constructs the client response with the origin status and body, but
passes an empty headers object to createResponse. Copy any required origin
response headers into that object before production use.
3. Place the EdgeWorker after App & API Protector
Order the EdgeWorker behavior after App & API Protector on the property. The WAF then runs first. TrustGuard evaluates only traffic that App & API Protector accepts, avoiding an evaluation call for requests the WAF rejects.4. Configure timeouts and failure behavior
An EdgeWorker has a 4-second wall-time budget, and it covers the guard call and the origin sub-request together, not each of them. The sample spendstimeout: 3000 on the guard call, which leaves about a second for your
origin. Measure your origin latency and set the guard timeout to leave enough
time for both calls.
The sample also has no try/catch. If TrustGuard is unreachable or the call
times out, the worker throws and the property handles the failed EdgeWorker.
Wrap the guard call and explicitly choose whether to continue to the origin
(fail open) or return an error (fail closed).
5. Activate the bundle
Upload the EdgeWorker version and activate it on staging before production. The property version carrying the path mapping and behavior order has to be activated too, not just the worker.6. Verify
- Put the policy in Enforce and POST a prompt to a guarded path that trips a rule.
- Confirm that the client receives 403 with the body
Blocked by TrustGuard. - Confirm the event in TrustGuard Activity, under the
consumer_idyou sent asX-User-Id.
Reference
Coverage
The integration evaluates input only and does not implement redaction. The
4-second wall-time budget covers both the evaluation and origin sub-requests.
The sample also omits origin response headers when it constructs the client
response.
What is evaluated
Every call is
POST /v1/evaluate with the collector
key as a bearer token, and the policy’s detectors decide the verdict. The worker
acts on status alone: block becomes a 403, and other verdicts continue. The
edge cannot prompt a user, so ask is allowed and recorded like report.
Configuration
Settings are defined in Property Manager and in the EdgeWorkers bundle.Attributes
consumer_id: from theX-User-Idheader. Per-consumer policy routing keys on it, and gates match it asconsumer.id, so without it every caller shares the collector’s default policy.session_id: from theX-Session-Idheader. The sample sends""when the header is absent. Send a stable, verified conversation ID if you need reliable grouping in Activity.- The edge derives neither. Your client has to send both headers, and
getHeader()returns them as arrays, so take[0].
Troubleshooting
Related
- Evaluate API: request and response contract for the endpoint the worker calls
- Policies: Observe and Enforce modes, including gate configuration
- Collectors: collector keys and policy resolution
- Other edge collectors: Cloudflare · CloudFront · Fastly
- Akamai EdgeWorkers docs: Akamai reference for
responseProviderand sub-requests