Connect Vercel AI SDK to Anoman AI
The Vercel AI SDK talks to Anoman through its OpenAI-compatible (or Anthropic) provider — generateText and streamText work unchanged.
Prerequisites
- An Anoman API key — create one in the dashboard (format anm-sk-…).
- Vercel AI SDK installed and up to date.
- A model ID from the Anoman catalog, e.g. gpt-4o, gpt-4o-mini, or claude-sonnet-4-6.
Enable streaming for long agent runs
Set stream: true on requests. Autonomous, multi-step, and long-thinking tasks can exceed the 100-second edge timeout and fail with a 524 error; streaming returns tokens as they are generated and keeps the connection alive, so the request completes. Most tools stream by default — confirm it is on for agentic use.
More detail in the streaming guide.
Create an Anoman provider
Use createOpenAICompatible from @ai-sdk/openai-compatible with Anoman's base URL and key.
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { streamText } from "ai";
const anoman = createOpenAICompatible({
name: "anoman",
apiKey: process.env.ANOMAN_API_KEY,
baseURL: "https://api.anoman.io/v1",
});
const { textStream } = await streamText({
model: anoman("gpt-4o"),
prompt: "Explain retrieval-augmented generation.",
});Prefer Anthropic?
Use createAnthropic from @ai-sdk/anthropic with Anoman's Anthropic base URL.
import { createAnthropic } from "@ai-sdk/anthropic";
const anoman = createAnthropic({
apiKey: process.env.ANOMAN_API_KEY,
baseURL: "https://api.anoman.io/anthropic",
});
// anoman("claude-sonnet-4-6")Verify the guardrails are active
Every Anoman response carries guardrail result headers. Inspect them in your dashboard traces to confirm the pipeline is running on Vercel AI SDK requests — prompt-injection detection, PII masking, and content moderation all apply automatically.
X-Anoman-Guardrail-Injection: pass score=0.03
X-Anoman-Guardrail-Pii: pass
X-Anoman-Guardrail-Content: pass
X-Anoman-Cache: noneNeed help with your integration?
Join the Founding 50 for early access and direct support from the Anoman team.
Join Founding 50