Key facts
| Plugsky endpoint | POST https://api.plugsky.com/v1/chat/completions |
| Provider setup | createOpenAI({ baseURL: "https://api.plugsky.com/v1", apiKey: "sk-live-…" }) |
| Model call | plugsky.chat("plugsky-pro") targets /v1/chat/completions across 30+ models |
| Streaming | streamText with a route handler response for UI streaming |
| Structured output | generateObject with a Zod schema uses JSON mode |
| Tools | AI SDK tool() maps to OpenAI function calling |
| Runtimes | Node 18+, Bun, Deno and edge runtimes with fetch |
| Product status | Live; the responses endpoint is coming soon on Plugsky, so keep using .chat() |
TL;DR
- One provider factory connects the AI SDK to Plugsky.
- Use .chat() on AI SDK 5 to avoid the Responses API path.
- streamText powers chat UIs through route handlers.
- generateObject with Zod gives typed structured output.
- Built-in tool definitions map to function calling.
How it works, step by step
- Install ai, @ai-sdk/openai and zod; set PLUGSKY_API_KEY.
- Create the provider with createOpenAI and the Plugsky base URL.
- Call generateText with plugsky.chat("plugsky-pro") and verify the output.
- Add a route handler using streamText for incremental UI updates.
- Define a Zod schema and extract typed data with generateObject.
- Add typed tools with input schemas and execute functions server-side.
- Deploy to Node or an edge runtime with the key bound as a server secret.
Original data
Try it yourself
Open the OpenAI-compatible API tester →
Create the provider
The AI SDK ships an OpenAI-compatible provider factory. Point it at Plugsky once and every model call inherits it:
npm install ai @ai-sdk/openai zodimport { createOpenAI } from "@ai-sdk/openai";
const plugsky = createOpenAI({
baseURL: "https://api.plugsky.com/v1",
apiKey: process.env.PLUGSKY_API_KEY,
});On AI SDK 5, call plugsky.chat("plugsky-pro") for chat models. Calling the provider as a function can route to the Responses API, which is coming soon on Plugsky — .chat() keeps requests on the live /v1/chat/completions endpoint. This is the single most common integration mistake.
generateText and streamText
A server-side generation is three lines:
import { generateText } from "ai";
const { text } = await generateText({
model: plugsky.chat("plugsky-pro"),
prompt: "Write a six-word release note for a latency fix.",
});For a chat UI, stream from a route handler. The AI SDK produces a stream response your frontend hooks consume directly:
import { streamText } from "ai";
export async function POST(req: Request) {
const { messages } = await req.json();
const result = streamText({
model: plugsky.chat("plugsky-lite"),
messages,
});
// AI SDK 4: return result.toDataStreamResponse();
// AI SDK 5:
return result.toUIMessageStreamResponse();
}Choose the model per route: plugsky-micro for autocomplete-style features, plugsky-pro for user-facing answers.
Structured output and tools
Zod schemas give you validated objects instead of parsing free text:
import { generateObject } from "ai";
import { z } from "zod";
const { object } = await generateObject({
model: plugsky.chat("plugsky-pro"),
schema: z.object({
title: z.string(),
tags: z.array(z.string()),
breaking: z.boolean(),
}),
prompt: "Extract release metadata from this changelog.",
});Tools follow the same pattern: define them with the AI SDK's tool() helper, give each an input schema and an execute function, and pass the tool set to generateText with a step limit. The SDK runs the loop, calling the model, executing tools and feeding results back — all through Plugsky's function-calling support. Keep execute functions server-side and validate their arguments before touching a database or external service.
Edge deployment and secrets
The provider uses fetch, so it runs on Vercel Edge Functions, Node, Bun, Deno and Cloudflare Workers. Two rules for deployment:
- Keep the key server-side: never expose it through a NEXT_PUBLIC variable or a client component. Route all model calls through route handlers or server actions.
- Bound latency: set a max duration on the route and pass an abort signal so abandoned requests stop generating tokens.
For observability, log the resolved model id and token usage per request; when you route across models, that data is the only way to explain quality or cost changes later. The responses endpoint, audio, images and batch are roadmap items on Plugsky, so keep workloads on chat completions, structured output and embeddings for now.
Honest comparison
| Capability | Plugsky + AI SDK | Raw fetch in a route handler | Self-hosted gateway |
|---|---|---|---|
| Setup | createOpenAI with baseURL | Hand-written fetch and parsing | Run and route a proxy layer |
| Streaming | streamText plus UI stream helpers | Manual SSE plumbing | Depends on the gateway |
| Structured output | generateObject with Zod | Prompt and validate yourself | Depends |
| Tools | tool() with schemas and execute | Manual tool loop | Custom dispatch |
| Edge runtimes | Vercel Edge, Workers, Bun and Deno | fetch works anywhere | Your own infrastructure |
| Ops | Managed API | Managed API | GPUs, scaling and upgrades |
Frequently asked questions
How do I configure Plugsky in the AI SDK?
Use createOpenAI({ baseURL: "https://api.plugsky.com/v1", apiKey }) and then reference models through that provider instance.
Why should I use plugsky.chat() instead of calling the provider directly?
On AI SDK 5 the default model path can use the Responses API, which is coming soon on Plugsky. .chat() targets /v1/chat/completions, which is live.
Does streaming work with the AI SDK?
Yes. streamText works, and on AI SDK 5 you return result.toUIMessageStreamResponse() from your route handler to stream to the UI.
Can I generate typed JSON?
Yes. generateObject with a Zod schema produces validated objects using JSON mode under the hood.
How do tools work?
Define tools with tool(), including an input schema and execute function, then pass them to generateText. The SDK runs the tool loop for you.
Which runtimes are supported?
Anything with fetch: Node 18+, Bun, Deno, Vercel Edge and Cloudflare Workers. Keep the API key in a server-side secret.
How do I control cost per route?
Choose the model per feature: plugsky-micro for cheap completions, plugsky-lite for chat, plugsky-pro for complex answers, and log token usage per request.
What is not available yet?
The responses endpoint, audio, images, moderation, files, batch and fine-tuning are coming soon; chat, streaming, tools, JSON mode and embeddings are live.