# Fine tuned model API integration into Square Space website

**URL:** <https://discuss.huggingface.co/t/fine-tuned-model-api-integration-into-square-space-website/164513>\
**Category:** Beginners\
**Created:** [July 25, 2025, 4:08pm UTC](https://discuss.huggingface.co/t/fine-tuned-model-api-integration-into-square-space-website/164513 "2025-07-25T16:08:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tuc111](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/tuc111/32/51703_2.png) [@tuc111](https://discuss.huggingface.co/u/tuc111)\
**Post date:** [July 25, 2025, 4:08pm UTC](https://discuss.huggingface.co/t/fine-tuned-model-api-integration-into-square-space-website/164513/1 "2025-07-25T16:08:28Z")

</div>

# Integrating a Fine-Tuned Model’s API into a Squarespace Website with Membership Access

Hello everyone 👋,

I’m working on deploying a fine-tuned language model (hosted privately on Hugging Face) and I’d like to integrate its API into my **Squarespace** website. The goal is to create a **custom page** on Squarespace where **members** (i.e. users who have signed up and paid for access) can interact with the model through a simple interface—possibly a chatbox or form submission.

I understand that Squarespace does not natively support full backend customization like a traditional server setup, so I know I’ll need to rely on **custom code blocks** , **JavaScript** , and potentially **external servers** for certain functionality. Here’s what I’m trying to figure out:

* * *

## ✅ What I Know

- I have a fine-tuned model deployed on Hugging Face with a **private inference endpoint**.
- Squarespace allows **custom code injection** using `<script>` tags via Code Blocks or Page Settings.
- Squarespace supports **membership gating** using their **Member Areas** feature.

* * *

## ❓ What I Need Help With

### 1. **Creating a Custom Member-Only Page**

- What’s the best way to create a private/custom page where only **approved members** can interact with my model?
- Can I conditionally render a custom UI (chat, form, etc.) based on membership level?
- How do I verify the user is logged in and paid before allowing access to the model?

### 2. **Calling the Hugging Face API Securely**

- Is it safe to call the Hugging Face inference endpoint directly from the browser using JavaScript?
  - I assume **no** , since this would expose the API key.

- Would I need a **middleware server** (e.g., a small Flask/FastAPI/Node.js app) to handle authenticated proxy requests to the model?
- If so, where would be the best place to host this kind of relay (e.g., Render, Vercel, Replit)?

### 3. **UI Suggestions**

- Has anyone here embedded a **chat-like interface** or **prompt/response** interface into Squarespace using custom JavaScript?
- Any tips for integrating input and response elements within Squarespace’s visual builder or using modals/popups?

* * *

## 🔒 Security and Access Control

- Is there a way to **throttle** requests or **log usage** per member?
- How do I prevent users from bypassing the frontend and hammering the API with spammy requests?

* * *

## Bonus: Stripe Integration for API Credits?

If anyone has experience offering **API access for credits** (e.g., Stripe + user credit balance + rate limiting), I’d love to hear your approach. I eventually want to offer **tiered plans** with usage caps.

* * *

### 🙏 Would Appreciate

- Code samples
- Middleware templates
- Project structure advice
- Any experience from folks who’ve done something similar

Thanks in advance!  
— _Emmitt_

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [July 25, 2025, 11:12pm UTC](https://discuss.huggingface.co/t/fine-tuned-model-api-integration-into-square-space-website/164513/2 "2025-07-25T23:12:04Z")

</div>

I’m not very good at JavaScript and UI, so I’ll leave that to someone else…

For now, since [server-side implementation seems difficult with Squarespace](https://stackoverflow.com/questions/77875960/can-you-run-server-side-code-on-squarespace), it would be best to [leave traffic management and other tasks to CloudFlare as much as possible](https://developers.cloudflare.com/durable-objects/examples/build-a-rate-limiter/).

> 2

There is virtually no way to safely call the API from browser code on its own. [With Spaces, embedding on other pages is possible in Public setting](https://discuss.huggingface.co/t/getting-a-cors-error-when-embedding-the-my-private-space/142466), and token obfuscation is possible with proper implementation, but the endpoint itself does not appear to have such functionality. The only option seems to be setting up a minimal proxy somewhere and handling the processing there.

### Examples (Hugging Face Endpoint with CloudFlare)

> **[GitHub - blue-pen5805/llm-proxy-on-cloudflare-workers: Serverless proxy built on Cloudflare Workers that...](https://github.com/blue-pen5805/llm-proxy-on-cloudflare-workers)**
>
> Serverless proxy built on Cloudflare Workers that integrates with multiple Large Language Model (LLM) APIs

> **[GitHub - lopins/serverless-api-proxy: Multi-API Proxy Gateway Based on Vercel Routes,...](https://github.com/lopins/serverless-api-proxy)**
>
> Multi-API Proxy Gateway Based on Vercel Routes, Cloudflare Workers, and Netlify Redirects

> **[GitHub - BerriAI/litellm: Python SDK, Proxy Server (AI Gateway) to call 100+...](https://github.com/BerriAI/litellm)**
>
> Python SDK, Proxy Server (AI Gateway) to call 100+ LLM APIs in OpenAI (or native) format, with cost tracking, guardrails, loadbalancing and logging. \[Bedrock, Azure, OpenAI, VertexAI, Cohere, Anthropic, Sagemaker, HuggingFace, VLLM, NVIDIA NIM\]

---

<div class="post-metadata">

**Author:** ![tuc111](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/tuc111/32/51703_2.png) [@tuc111](https://discuss.huggingface.co/u/tuc111)\
**Post date:** [July 30, 2025, 5:09pm UTC](https://discuss.huggingface.co/t/fine-tuned-model-api-integration-into-square-space-website/164513/3 "2025-07-30T17:09:13Z")

</div>

Thank you! I don’t think I’ll move forward with my demo on squarespace.
