← All integrations

Integration · Vercel AI SDK

Manage Vercel AI SDK Prompt Templates Externally

The Vercel AI SDK unifies every provider behind one API. PromptForge unifies every system prompt behind one REST endpoint — fetch once, inject into generateText, swap models freely.

Integration Example

PromptForge + Vercel AI SDK in one file

Version, template, and serve prompts for the Vercel AI SDK via REST API. Fetch your system prompt from PromptForge, pass it to generateText or streamText, and switch between @ai-sdk/openai, @ai-sdk/anthropic, or @ai-sdk/google without changing prompt management code.

  1. 1
  2. Fetch your versioned, interpolated prompt from the PromptForge REST API with a single fetch() call.
  3. 2
  4. Pass the returned content string directly to the Vercel AI SDK SDK as the system prompt, no transformation needed.
  5. 3
  6. Update the prompt in the PromptForge dashboard anytime, running applications pick up the change on the next request. No redeployment required.
ai-sdk-route.ts
TypeScript
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
// Swap for @ai-sdk/anthropic, @ai-sdk/google, @ai-sdk/xai, etc.

async function fetchPrompt(role: string, task: string) {
  const res = await fetch(
    "https://www.promptforge-app.com/api/v1/prompts/your-prompt-id",
    {
      method: "POST",
      headers: {
        Authorization: "Bearer pfk_your_api_key",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        version: "stable",
        variables: { role, task },
      }),
    }
  );
  const { content } = await res.json();
  return content as string;
}

// 1. Fetch versioned system prompt from PromptForge
const system = await fetchPrompt("support agent", "billing inquiries");

// 2. Pass to any AI SDK provider — model swap does not touch prompt management
const { text } = await generateText({
  model: openai("gpt-4o"),
  system,
  prompt: "A customer says they were double-charged. How do I help?",
});

console.log(text);
How It Works

Vercel AI SDK + PromptForge in Three Steps

Add a prompt management layer to your Vercel AI SDK integration without refactoring your application.

Step 1

Author prompts once, use with any @ai-sdk provider

PromptForge returns plain text. Pass it as the system field in generateText regardless of whether you call OpenAI, Anthropic, Google, or xAI.

Step 2

Version prompts independently from model routing

Changing from openai() to anthropic() is a one-line model swap. Prompt wording stays in PromptForge with full version history and rollback.

Step 3

Fetch in your Route Handler or Server Action

Call PromptForge from app/api/chat/route.ts before generateText or streamText. Running apps pick up prompt changes on the next request.

Features

Powerful Prompt Management Features for AI Developers

From simple prompt storage to production-ready APIs with version control, dynamic variables, rollback, and a public gallery.

Dynamic Variables

Use {{variable}} syntax to create reusable prompt templates. Pass different values via API for endless customization across any LLM.

Instant Prompt API

RESTful API endpoint ready in seconds. Fetch any prompt with version pinning and variable interpolation. No redeployment needed.

Rollback with Diff Checker

View a line-by-line diff of every change and roll back to any previous version in one click. Never lose a working prompt again.

Publish to Gallery

Share your best prompts with the community in the public gallery. Get discovered by other developers and grow your personal library.

Start for free, upgrade anytime

No credit card required to get started. Paid plans include a 14-day free trial.

Developer Sandbox
Hobby Plan
$0/ forever
  • 1 Production Prompt
  • 1,000 API Requests/mo
  • Stable/Latest Channel Routing
  • No Credit Card Required
Launch Sandbox
Starter
14-day free trial
$9/month

No charge until your trial ends

  • 10k API requests/month
  • 5 prompt
  • Unlimited versions
  • Dynamic variables
  • Version pinning
  • API key management
Start 14-Day Free Trial
Most Popular
Pro
14-day free trial
$29/month

No charge until your trial ends

  • 100k API requests/month
  • 25 prompt
  • Unlimited versions
  • Dynamic variables
  • Version pinning
  • API key management
Start 14-Day Free Trial
Business
14-day free trial
$49/month

No charge until your trial ends

  • 500k API requests/month
  • 100 prompt
  • Unlimited versions
  • Dynamic variables
  • Version pinning
  • API key management
Start 14-Day Free Trial

Questions? Contact us

FAQ

Vercel AI SDK + PromptForge: Common Questions

Specific answers for developers integrating PromptForge with Vercel AI SDK.

Does PromptForge work with streamText and the AI SDK UI hooks?

Yes. Fetch the system prompt before calling streamText. The PromptForge fetch is a one-time call per request; streaming behaviour is unchanged.

Can I use the same PromptForge template across multiple AI SDK providers?

Yes. PromptForge returns provider-agnostic plain text. The same template works with openai(), anthropic(), google(), and xai() model constructors.

How do I use PromptForge with generateObject?

Store the system instructions that define output shape and behaviour in PromptForge. Fetch at runtime and pass as the system parameter alongside your schema in generateObject.

Where should the PromptForge API call live in a Next.js App Router project?

Call PromptForge from a Server Action, Route Handler, or server-only utility imported by your API route — never from a client component if your API key must stay secret.