Vercel AI SDK
Optimize AI SDK streaming responses with Promptly
Use Promptly with Vercel AI SDK to reduce costs on streaming LLM responses in Next.js, SvelteKit, and other frameworks. Drop-in replacement with full streaming support.
Setup Guide
Install Dependencies
Install Vercel AI SDK and the OpenAI provider.
npm install ai @ai-sdk/openaiConfigure the Provider
Create a custom OpenAI provider pointing to Promptly. Use this across your app.
import { createOpenAI } from "@ai-sdk/openai";
const promptly = createOpenAI({
apiKey: "sk-promptly-...",
baseURL: "https://api.getpromptly.in/v1",
});
export default promptly;Use in API Routes
Streaming works perfectly. Every streamed response is optimized - prompts compressed, conversations pruned, simple queries routed to cheaper models.
import { streamText } from "ai";
import promptly from "@/lib/promptly";
export async function POST(req: Request) {
const { messages } = await req.json();
const result = streamText({
model: promptly("gpt-4o"),
messages,
});
return result.toDataStreamResponse();
}Why Use Promptly with Vercel AI SDK?
- Full streaming support with zero overhead
- Works with useChat, useCompletion, and all AI SDK hooks
- Automatic context pruning for chat conversations
- Cost analytics per API route in Promptly dashboard
- Compatible with Next.js, SvelteKit, Nuxt, and SolidStart
Start optimizing Vercel AI SDK costs
Sign up, grab your API key, and change your base URL. Under 2 minutes.
Other Integrations
Promptly Python SDK
Official Python SDK - the fastest way to get started
Promptly Node.js SDK
Official Node.js SDK - TypeScript-first, zero config
LangChain
Use Promptly as your LLM backend in LangChain
LlamaIndex
Optimize your RAG pipeline costs with Promptly
OpenAI Python SDK
Drop-in optimization for the official OpenAI Python library