← Blog

Claude API Webflow Integration Guide

2026-11-24 · 5 min read · SubToAPI Team

Webflow sites don't run server-side code, so you can't call Claude's API directly from a Webflow page without exposing your API key to every visitor. The practical solution is a small backend proxy that sits between your Webflow frontend and the Claude API, and this guide walks through exactly how to build that connection — from getting API access to wiring up a chat widget or form inside Webflow's custom code embed.

If you've tried pasting an API key into a Webflow custom code block and calling api.anthropic.com directly, you've probably hit CORS errors or realized your key is sitting in plain view in the page source. That's not a Webflow limitation specifically — it's how any client-rendered site has to handle secrets. The fix is always the same: keep the key server-side, and let Webflow talk to your own lightweight endpoint instead.

Why Webflow needs a middle layer

Webflow is excellent for marketing sites, landing pages, and content-driven apps, but it has no native server runtime. Anything you add through the custom code panel runs in the visitor's browser. That means:

The backend can be as small as a single serverless function. You're not building a full application server — just a few lines of code that forward a prompt, attach your API key, and return the response.

Step 1: Get an API endpoint and key

You can call Anthropic's API directly, but if you want a simpler setup with application-scoped keys, usage metadata, and a dashboard to manage access, SubToAPI turns your existing Claude access into a standard HTTPS API. Sign up at /signup, grab a sub_live_... key from the dashboard, and you're ready to make requests from a server-side environment.

curl https://api.subtoapi.app/v1/messages \
  -H "Authorization: Bearer $SUBTOAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4",
    "max_tokens": 500,
    "messages": [
      {"role": "user", "content": "Summarize this product in two sentences: ..."}
    ]
  }'

Check /docs/quickstart for the full request/response reference and /docs/messages for message formatting details.

Step 2: Build a small proxy function

Any serverless platform works — Cloudflare Workers, Netlify Functions, Vercel, or a basic Node/Express endpoint. The job of this function is simple: accept a request from your Webflow page, call the Claude API, and return the result with CORS headers set for your domain.

// api/ask.js — example Netlify/Vercel style function
export default async function handler(req, res) {
  res.setHeader('Access-Control-Allow-Origin', 'https://yoursite.webflow.io');
  res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');
  res.setHeader('Access-Control-Allow-Headers', 'Content-Type');

  if (req.method === 'OPTIONS') return res.status(200).end();

  const { prompt } = req.body;

  const response = await fetch('https://api.subtoapi.app/v1/messages', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.SUBTOAPI_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'claude-sonnet-4',
      max_tokens: 400,
      messages: [{ role: 'user', content: prompt }],
    }),
  });

  const data = await response.json();
  res.status(200).json({ text: data.content?.[0]?.text ?? '' });
}

Deploy this to any serverless host. Once you have a live URL (e.g., https://your-proxy.vercel.app/api/ask), that's the only address your Webflow site needs to know about.

Step 3: Add the frontend in Webflow

Inside Webflow, add a form or a simple div with an input and button using the Designer, then drop a custom code embed (Page Settings → Custom Code, or an Embed element) with the fetch logic:

<script>
  async function askClaude() {
    const input = document.getElementById('user-input').value;
    const output = document.getElementById('response-box');
    output.innerText = 'Thinking...';

    const res = await fetch('https://your-proxy.vercel.app/api/ask', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ prompt: input }),
    });

    const data = await res.json();
    output.innerText = data.text;
  }
</script>

Bind askClaude() to a button click in the Webflow Designer, or attach the event listener in the embed script itself. This pattern works for FAQ bots, content generators, product recommendation widgets, or support assistants embedded directly on a Webflow page.

Step 4: Handle streaming for better UX

For longer responses, streaming avoids making visitors stare at a blank box while the full answer generates. SubToAPI supports streaming responses over the same endpoint structure — see /docs/streaming for the event format. Your proxy function needs to forward the stream (using ReadableStream or SSE) rather than waiting for the full completion, and your Webflow-side script reads chunks as they arrive and appends them to the output element.

Step 5: Add tool use if the widget needs to act, not just answer

If your Webflow integration should do more than generate text — like look up order status, search a product catalog, or submit a lead — Claude's tool use feature lets the model call functions you define and return structured results. This is handled entirely in your proxy function; Webflow only ever sees the final text or JSON. Details are in /docs/tools.

Keep it secure and within plan limits

A few practical notes before going live:

Questions

Can I call Claude's API directly from Webflow's custom code without a backend? No. Webflow runs custom code in the browser, so any API key included would be publicly visible. You need a server-side proxy (serverless function or small backend) to keep the key secure and handle the request.

Does Webflow have a built-in integration for Claude or AI APIs? Not natively. Webflow's own AI features are separate from Anthropic's Claude. For custom Claude-powered features, you build your own connection using custom code plus an external API endpoint.

What's the fastest way to add a Claude-powered chatbot to an existing Webflow site? Deploy a single serverless function that calls Claude (directly or through a service like SubToAPI), then embed a short fetch script in a Webflow custom code block. Most teams get a working proof of concept running within a day using this pattern.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →