{
  "slug": "anthropic-claude-api-frontend-proxy",
  "title": "Secure Anthropic Claude API Proxy for Frontend",
  "metaTitle": "Secure Anthropic Claude API Proxy - RealComposer",
  "metaDescription": "Secure anthropic claude api proxy for frontend. Keep Anthropic keys in RealComposer Vault; Frontend / Web uses rc_live_ tokens only.",
  "headline": "Vault-backed Anthropic proxy tuned for Frontend / Web",
  "category": "security",
  "categoryLabel": "Security & Secret Vault",
  "urgency": 9,
  "clientPlatform": "Frontend / Web",
  "upstreamServices": [
    "Anthropic"
  ],
  "searchIntentQuery": "secure anthropic claude api proxy for frontend",
  "directAnswerSummary": "Never place ANTHROPIC_API_KEY inside Frontend / Web source. RealComposer injects them when calling https://api.anthropic.com/v1/messages, so browsers see only a client token.",
  "problem": {
    "title": "Anthropic keys in Frontend / Web network tabs",
    "explanation": "Frontend / Web ships code or scripts to end-user devices. Any Anthropic bearer token in those bundles can be copied from DevTools, proxies, or repackaged apps.",
    "risks": [
      "Shared Frontend / Web projects revealing Anthropic tokens",
      "Sudden Anthropic quota burn from scripted abuse",
      "Inability to rotate keys without redeploying clients"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Add vault secrets for this pipeline",
      "description": "Store ANTHROPIC_API_KEY in the vault. Frontend / Web never embeds the raw secret, only a revocable rc_live_ client token."
    },
    {
      "stepNumber": 2,
      "title": "Configure upstream steps and output mapping",
      "description": "Configure headersTemplate to inject vault secrets, target https://api.anthropic.com/v1/messages, and Add output mapping fields that mirror the JSON contract your screen already expects."
    },
    {
      "stepNumber": 3,
      "title": "Call from Frontend / Web",
      "description": "Allowed origins on the token should list every Frontend / Web host that calls this URL.",
      "codeSnippet": "const res = await fetch('https://realcomposer.com/v1/workspace/anthropic-claude-api-frontend-proxy', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "Secure Anthropic Claude API Proxy for Frontend",
    "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_anthropi",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "anthropic-claude-api-frontend-proxy"
    },
    "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/anthropic-claude-api-frontend-proxy\" \\\n  -H \"Authorization: Bearer rc_live_client_token\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"model\":\"example\"}'",
  "faqs": [
    {
      "question": "Which Anthropic credential belongs in the vault for this pipeline?",
      "answer": "Yes for anthropic-claude-api-frontend-proxy. Ship only an rc_live_ client token in Frontend / Web; RealComposer injects ANTHROPIC_API_KEY on https://api.anthropic.com/v1/messages."
    },
    {
      "question": "What cache key does RealComposer use?",
      "answer": "anthropic-claude-api-frontend-proxy vault headers attach server-side, but Anthropic or OpenAI model and messages must come from the client body."
    },
    {
      "question": "What happens if an upstream step times out?",
      "answer": "Upstream steps in anthropic-claude-api-frontend-proxy honor timeoutMs and optional fallback JSON without leaking secrets."
    }
  ],
  "relatedRecipeSlugs": [
    "reduce-json-size-flutter-app",
    "slim-github-api-response-mobile-widgets",
    "api-composition-tool-low-code"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/anthropic-claude-api-frontend-proxy",
    "markdown": "https://realcomposer.com/recipes/anthropic-claude-api-frontend-proxy.md",
    "json": "https://realcomposer.com/recipes/anthropic-claude-api-frontend-proxy.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=anthropic-claude-api-frontend-proxy&via=agent"
  }
}