Recipes

Integration patterns for common agent frameworks and platforms.

Claude Desktop (MCP)

See Quickstart: MCP for the full setup. Once configured, Claude can provision domains directly in conversation.

LangChain (Python)

from langchain.tools import StructuredTool
import requests

API_KEY = "th_live_your_key"
API_URL = "https://thin.host/v1"

def provision_domain(domain: str, origin_url: str, user_email: str) -> dict:
    """Provision a custom domain via thin.host."""
    resp = requests.post(
        f"{API_URL}/domains",
        headers={"X-Platform-API-Key": API_KEY},
        json={"domain": domain, "origin_url": origin_url, "end_user_email": user_email},
    )
    return resp.json()

tool = StructuredTool.from_function(
    func=provision_domain,
    name="provision_domain",
    description="Provision a custom domain for a deployed site. Returns a claim_url for the user.",
)

Vercel AI SDK (TypeScript)

import { tool } from "ai";
import { z } from "zod";

const provisionDomain = tool({
  description: "Provision a custom domain via thin.host",
  parameters: z.object({
    domain: z.string().describe("Custom domain to provision"),
    origin_url: z.string().describe("Origin URL to proxy to"),
    user_email: z.string().describe("End user email for billing"),
  }),
  execute: async ({ domain, origin_url, user_email }) => {
    const resp = await fetch("https://thin.host/v1/domains", {
      method: "POST",
      headers: {
        "X-Platform-API-Key": process.env.THIN_HOST_API_KEY!,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ domain, origin_url, end_user_email: user_email }),
    });
    return resp.json();
  },
});

OpenAI Agents SDK (Python)

from agents import function_tool
import requests

API_KEY = "th_live_your_key"

@function_tool
def provision_domain(domain: str, origin_url: str, user_email: str) -> dict:
    """Provision a custom domain. Returns claim_url for the user to pay and configure DNS."""
    resp = requests.post(
        "https://thin.host/v1/domains",
        headers={"X-Platform-API-Key": API_KEY},
        json={"domain": domain, "origin_url": origin_url, "end_user_email": user_email},
    )
    return resp.json()

Webhook Integration

# Flask webhook handler
@app.route("/webhooks/thinhost", methods=["POST"])
def thinhost_webhook():
    data = request.json
    if data["event"] == "payment_completed":
        # User paid — domain moving to DNS setup
        notify_user(data["domain_id"], "Payment received! Configure DNS next.")
    elif data["event"] == "domain_active":
        # Domain is fully live
        notify_user(data["domain_id"], f"Your domain {data['hostname']} is live!")
    return "", 200