{
  "slug": "combine-anthropic-supabase-vector-rag",
  "title": "Combine anthropic with supabase vector rag search",
  "metaTitle": "Combine anthropic with supabase - RealComposer",
  "metaDescription": "Combine anthropic with supabase vector rag search. Merge Anthropic and Supabase in one Next.js / React call with parallel Worker steps.",
  "headline": "RAG answer pipeline in one call",
  "category": "aggregation",
  "categoryLabel": "Multi-API Aggregation",
  "urgency": 9,
  "clientPlatform": "Next.js / React",
  "upstreamServices": [
    "Anthropic",
    "Supabase"
  ],
  "searchIntentQuery": "combine anthropic with supabase vector rag search",
  "directAnswerSummary": "Anthropic completion plus Supabase vector match results composed at edge. For \"combine anthropic with supabase vector rag search\", store ANTHROPIC_API_KEY, SUPABASE_SERVICE_ROLE_KEY in Secret Vault, call https://api.anthropic.com/v1/messages from a Worker, and let Next.js / React hit only https://realcomposer.com/v1/workspace/combine-anthropic-supabase-vector-rag 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": "Waterfall latency from multiple Anthropic and Supabase requests",
    "explanation": "Next.js / React widgets often await Anthropic and Supabase sequentially, multiplying TLS handshakes on cellular networks and amplifying failure rates.",
    "risks": [
      "Race conditions between parallel manual fetches",
      "Higher mobile data usage from redundant JSON",
      "Timeouts when any upstream exceeds cellular RTT"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Store upstream credentials in Secret Vault",
      "description": "Add ANTHROPIC_API_KEY, SUPABASE_SERVICE_ROLE_KEY to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream."
    },
    {
      "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 Next.js / React",
      "description": "Allowed origins on the token should list every Next.js / React host that calls this URL.",
      "codeSnippet": "// app/api route or client component\nconst res = await fetch('https://realcomposer.com/v1/workspace/combine-anthropic-supabase-vector-rag', {\n  cache: 'no-store',\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "Combine anthropic with supabase vector rag search",
    "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
      },
      {
        "stepKey": "supabase",
        "upstreamUrlTemplate": "https://{{secrets.SUPABASE_PROJECT_REF}}.supabase.co/rest/v1/{{query.table}}?{{query.filter}}",
        "httpMethod": "GET",
        "headersTemplate": {
          "apikey": "{{secrets.SUPABASE_SERVICE_ROLE_KEY}}",
          "Authorization": "Bearer {{secrets.SUPABASE_SERVICE_ROLE_KEY}}"
        },
        "timeoutMs": 3000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "anthropic.role",
          "sourcePath": "content.0.text",
          "type": "string",
          "sourceStep": "anthropic"
        },
        {
          "targetPath": "anthropic.model",
          "sourcePath": "model",
          "type": "string",
          "sourceStep": "anthropic"
        },
        {
          "targetPath": "supabase.rowId",
          "sourcePath": "0.id",
          "type": "string",
          "sourceStep": "supabase"
        },
        {
          "targetPath": "supabase.email",
          "sourcePath": "0.email",
          "type": "string",
          "sourceStep": "supabase"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_combine-",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "combine-anthropic-supabase-vector-rag"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "anthropic_role": "sample",
    "anthropic_model": "sample",
    "supabase_rowId": "sample",
    "supabase_email": "sample"
  },
  "curlSnippet": "curl -X POST \"https://realcomposer.com/v1/workspace/combine-anthropic-supabase-vector-rag\" \\\n  -H \"Authorization: Bearer rc_live_client_token\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"model\":\"example\"}'",
  "faqs": [
    {
      "question": "Does Next.js / React need CORS changes after adding RealComposer?",
      "answer": "Yes for combine-anthropic-supabase-vector-rag. Ship only an rc_live_ client token in Next.js / React; RealComposer injects ANTHROPIC_API_KEY on https://api.anthropic.com/v1/messages."
    },
    {
      "question": "What cache key does RealComposer use?",
      "answer": "combine-anthropic-supabase-vector-rag forwards client JSON to POST upstreams unchanged; secrets interpolate only in URLs and header templates."
    },
    {
      "question": "Can I restrict which domains call this pipeline?",
      "answer": "Allowed origins on the combine-anthropic-supabase-vector-rag client token restrict which domains may call the edge URL."
    }
  ],
  "relatedRecipeSlugs": [
    "combine-openai-and-supabase-vector-search",
    "anthropic-api-proxy-flutterflow"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/combine-anthropic-supabase-vector-rag",
    "markdown": "https://realcomposer.com/recipes/combine-anthropic-supabase-vector-rag.md",
    "json": "https://realcomposer.com/recipes/combine-anthropic-supabase-vector-rag.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=combine-anthropic-supabase-vector-rag&via=agent"
  }
}