> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neuraltrust.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Akamai EdgeWorkers

> TrustGuard from EdgeWorkers responseProvider.

Sub-requests only reach hosts on your Akamai property. Map TrustGuard under a path first.

1. Property Manager: route e.g. `/trustguard/*` to the TrustGuard origin.
2. EdgeWorker `responseProvider` after App & API Protector.
3. Stay inside the \~4s wall clock — set a sub-request timeout and pick fail-open vs closed.
4. Activate and test.

```js theme={null}
import { httpRequest } from "http-request";
import { createResponse } from "create-response";

export async function responseProvider(request) {
  if (request.method === "POST") {
    const text = await request.text();
    const guardResponse = await httpRequest("/trustguard/v1/evaluate", {
      method: "POST",
      headers: {
        Authorization: "Bearer <collector-api-key>",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        protocol: "llm",
        direction: "input",
        payload: { input: text },
        consumer_id: request.getHeader("X-User-Id")?.[0] ?? "",
        session_id: request.getHeader("X-Session-Id")?.[0] ?? "",
      }),
      timeout: 3000,
    });
    const result = await guardResponse.json();

    if (result.status === "block") {
      return createResponse(403, {}, "Blocked by TrustGuard");
    }

    const forwardBody =
      result.status === "transform" && result.transformed_payload
        ? JSON.stringify(result.transformed_payload)
        : text;

    const originResponse = await httpRequest(request.url, {
      method: "POST",
      headers: { "Content-Type": request.getHeader("Content-Type") ?? "" },
      body: forwardBody,
    });
    return createResponse(originResponse.status, {}, originResponse.body);
  }

  const originResponse = await httpRequest(request.url);
  return createResponse(originResponse.status, {}, originResponse.body);
}
```
