Get 30% extra credits if you sign up todayends in --:--:--

Integrations / Vercel AI SDK

Vercel AI SDK tools to send SMS and email

There is no Node SDK and none is needed: Hail is a REST API with bearer auth. Two fetch-based tools give a Vercel AI SDK agent texting and email.

01Set the key

Create an API key in the Hail console and expose it to your server runtime only.

# .env.local
HAIL_API_KEY="hl_live_9fa2..."

02Define the tools

The AI SDK's tool() takes a Zod schema and an execute function. recipient_consent is a required field; the API refuses a send without it.

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

const hail = (path: string, body: unknown) =>
  fetch(`https://api.hail.so${path}`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.HAIL_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(body),
  }).then((r) => r.json());

const sendSms = tool({
  description: "Text an opted-in recipient.",
  inputSchema: z.object({ to: z.string(), body: z.string() }),
  execute: ({ to, body }) =>
    hail("/sms", { to, body, recipient_consent: true }),
});

03Use them in generateText

The model picks the channel. Delivery events come back on your webhook.

const { text } = await generateText({
  model: "anthropic/claude-sonnet-5",
  tools: { sendSms },
  prompt: "Text +14155550142 that order 4471 shipped.",
});

Questions

Is there a Hail Node SDK?

No, and the examples do not need one. The REST API takes a bearer key; fetch covers it. An OpenAPI spec is available for typed clients.

Where do delivery receipts go?

Register a webhook URL. Hail signs every delivery and retries on a fixed ladder, so your route handler can trust and dedupe events.

Ship it with a real number

Sign up, grab a key, and the examples above run as written. Pay per use, no subscription.

Get started →

More frameworks

LangGraph · CrewAI · OpenAI Agents SDK · n8n · Claude