{
  "slug": "slim-anthropic-streaming-payload-edge",
  "title": "Anthropic streaming api payload slim edge proxy",
  "metaTitle": "Anthropic streaming api payload - RealComposer",
  "metaDescription": "Anthropic streaming api payload slim edge proxy. Edge strips rate limit headers and debug from streamed. Map only UI fields from Anthropic before.",
  "headline": "Streaming chat with minimal non-content keys",
  "category": "slimmer",
  "categoryLabel": "Payload Slimmer",
  "urgency": 8,
  "clientPlatform": "Frontend / Web",
  "upstreamServices": [
    "Anthropic"
  ],
  "searchIntentQuery": "anthropic streaming api payload slim edge proxy",
  "directAnswerSummary": "Edge strips rate limit headers and debug from streamed JSON chunks. For \"anthropic streaming api payload slim edge proxy\", store ANTHROPIC_API_KEY in Secret Vault, call https://api.anthropic.com/v1/messages from a Worker, and let Frontend / Web hit only https://realcomposer.com/v1/workspace/slim-anthropic-streaming-payload-edge with an rc_live_ client token. POST upstream calls are not stored in caches.default; clients must send JSON bodies and headers forward unchanged.",
  "problem": {
    "title": "Unmapped Anthropic fields waste bandwidth",
    "explanation": "Anthropic returns nested CRM, audit, and configuration objects. Frontend / Web parses them on the main thread even when the UI binds three fields.",
    "risks": [
      "Large arrays kept in memory after navigation",
      "Analytics showing poor LCP on API-heavy screens",
      "Developers shipping defensive null checks for unused paths"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Bind vault keys to the Worker",
      "description": "Create ANTHROPIC_API_KEY vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders."
    },
    {
      "stepNumber": 2,
      "title": "Set headers, mapping, and cache TTL",
      "description": "Point step anthropic at https://api.anthropic.com/v1/messages with POST. Map only the UI fields in output mapping so clients never download audit or nested blobs. POST pipelines set cache TTL to 0 because RealComposer only stores GET responses at the edge."
    },
    {
      "stepNumber": 3,
      "title": "Call from Frontend / Web",
      "description": "Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.",
      "codeSnippet": "const res = await fetch('https://realcomposer.com/v1/workspace/slim-anthropic-streaming-payload-edge', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "Anthropic streaming api payload slim edge proxy",
    "method": "POST",
    "cacheTtlSeconds": 0,
    "authMode": "client_token",
    "steps": [
      {
        "stepKey": "anthropic",
        "upstreamUrlTemplate": "https://api.anthropic.com/v1/messages",
        "httpMethod": "POST",
        "headersTemplate": {
          "x-api-key": "{{secrets.ANTHROPIC_API_KEY}}",
          "anthropic-version": "2023-06-01",
          "Content-Type": "application/json"
        },
        "timeoutMs": 10000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "role",
          "sourcePath": "content.0.text",
          "type": "string",
          "sourceStep": "anthropic"
        },
        {
          "targetPath": "model",
          "sourcePath": "model",
          "type": "string",
          "sourceStep": "anthropic"
        },
        {
          "targetPath": "stopReason",
          "sourcePath": "stop_reason",
          "type": "string",
          "sourceStep": "anthropic"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_slim-ant",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "slim-anthropic-streaming-payload-edge"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "role": "sample",
    "model": "sample",
    "stopReason": "sample"
  },
  "curlSnippet": "curl -X POST \"https://realcomposer.com/v1/workspace/slim-anthropic-streaming-payload-edge\" \\\n  -H \"Authorization: Bearer rc_live_client_token\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"model\":\"example\"}'",
  "faqs": [
    {
      "question": "What should Frontend / Web store instead of Anthropic secrets?",
      "answer": "Point Frontend / Web at /recipes/slim-anthropic-streaming-payload-edge edge URL. RealComposer answers OPTIONS with Access-Control headers for allowed origins."
    },
    {
      "question": "Will Anthropic or Linear prompt bodies be rewritten?",
      "answer": "slim-anthropic-streaming-payload-edge vault headers attach server-side, but Anthropic or OpenAI model and messages must come from the client body."
    },
    {
      "question": "How do I rotate upstream credentials?",
      "answer": "Rotate vault secrets for slim-anthropic-streaming-payload-edge anytime; clients keep the same rc_live_ token."
    }
  ],
  "relatedRecipeSlugs": [
    "filter-json-response-at-edge",
    "slim-anthropic-messages-response-chat"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/slim-anthropic-streaming-payload-edge",
    "markdown": "https://realcomposer.com/recipes/slim-anthropic-streaming-payload-edge.md",
    "json": "https://realcomposer.com/recipes/slim-anthropic-streaming-payload-edge.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=slim-anthropic-streaming-payload-edge&via=agent"
  }
}