{
  "slug": "cache-anthropic-api-prompt-previews",
  "title": "Cache anthropic api for repeated prompt previews",
  "metaTitle": "Cache anthropic api for repeated - RealComposer",
  "metaDescription": "Cache anthropic api for repeated prompt previews. Shield Anthropic with no POST edge cache; cache key uses query params on.",
  "headline": "Marketing demos with repeated sample prompts",
  "category": "caching",
  "categoryLabel": "Edge Caching & Rate Limits",
  "urgency": 7,
  "clientPlatform": "Framer",
  "upstreamServices": [
    "Anthropic"
  ],
  "searchIntentQuery": "cache anthropic api for repeated prompt previews",
  "directAnswerSummary": "Short TTL cache on identical preview completions (non-production). For \"cache anthropic api for repeated prompt previews\", store ANTHROPIC_API_KEY in Secret Vault, call https://api.anthropic.com/v1/messages from a Worker, and let Framer hit only https://realcomposer.com/v1/workspace/cache-anthropic-api-prompt-previews 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": "Anthropic rate limits from Framer traffic",
    "explanation": "Without edge caching, identical Anthropic reads during a session still round-trip to the origin.",
    "risks": [
      "HTTP 429 responses during launch traffic",
      "Surprise SaaS overages from duplicate reads",
      "Slower repeat views than necessary"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Store upstream credentials in Secret Vault",
      "description": "Create ANTHROPIC_API_KEY vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders."
    },
    {
      "stepNumber": 2,
      "title": "Configure upstream steps and output mapping",
      "description": "Use POST against https://api.anthropic.com/v1/messages. Allowed origins on the client token should match post pipelines set cache ttl to 0 because realcomposer only stores get responses at the edge."
    },
    {
      "stepNumber": 3,
      "title": "Fetch inside Framer overrides",
      "description": "Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.",
      "codeSnippet": "fetch('https://realcomposer.com/v1/workspace/cache-anthropic-api-prompt-previews', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "Cache anthropic api for repeated prompt previews",
    "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_cache-an",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "cache-anthropic-api-prompt-previews"
    },
    "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/cache-anthropic-api-prompt-previews\" \\\n  -H \"Authorization: Bearer rc_live_client_token\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"model\":\"example\"}'",
  "faqs": [
    {
      "question": "Is it safe to log Anthropic responses in Framer?",
      "answer": "Store ANTHROPIC_API_KEY for cache-anthropic-api-prompt-previews. Framer never sees decrypted values."
    },
    {
      "question": "When does edge caching apply to this recipe?",
      "answer": "cache-anthropic-api-prompt-previews vault headers attach server-side, but Anthropic or OpenAI model and messages must come from the client body."
    },
    {
      "question": "Can I restrict which domains call this pipeline?",
      "answer": "Upstream steps in cache-anthropic-api-prompt-previews honor timeoutMs and optional fallback JSON without leaking secrets."
    }
  ],
  "relatedRecipeSlugs": [
    "hide-openai-api-key-react",
    "hide-anthropic-api-key-nextjs"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/cache-anthropic-api-prompt-previews",
    "markdown": "https://realcomposer.com/recipes/cache-anthropic-api-prompt-previews.md",
    "json": "https://realcomposer.com/recipes/cache-anthropic-api-prompt-previews.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=cache-anthropic-api-prompt-previews&via=agent"
  }
}