Use Cases
The Vercel AI SDK is a TypeScript toolkit for AI applications, commonly used in Next.js, React, Vue, Svelte, and Node.js projects. It provides an OpenAI Compatible provider that lets you integrate Tokener CA into generateText, streamText, tool calls, and chat interfaces.
The integration values are as follows:
| Setting | Value |
|---|---|
| package | @ai-sdk/openai-compatible |
| baseURL | https://a.skypool.xyz/v1 |
| apiKey | Consumer API Key, for example stc-... |
| model | Platform model name, for example gemma4:26b |
Install Dependencies
pnpm add ai @ai-sdk/openai-compatiblenpm:
npm install ai @ai-sdk/openai-compatibleConfigure Environment Variables
Add the following to .env.local:
SKYPOOL_API_KEY=stc-...Do not commit real API keys to the repository.
Non-Streaming Call
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";import { generateText } from "ai"; const skypool = createOpenAICompatible({ name: "skypool", baseURL: "https://a.skypool.xyz/v1", apiKey: process.env.SKYPOOL_API_KEY,}); const { text, usage, finishReason } = await generateText({ model: skypool.chatModel("gemma4:26b"), prompt: "In one sentence, explain that the Vercel AI SDK is already integrated with Tokener CA.", maxOutputTokens: 128,}); console.log(text);console.log(usage);console.log(finishReason);If your AI SDK version supports calling the provider directly, you can also write the model as skypool("gemma4:26b"). To reduce version differences, the examples in this article use the explicit chatModel.
Streaming Call
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";import { streamText } from "ai"; const skypool = createOpenAICompatible({ name: "skypool", baseURL: "https://a.skypool.xyz/v1", apiKey: process.env.SKYPOOL_API_KEY,}); const result = streamText({ model: skypool.chatModel("gemma4:26b"), prompt: "Introduce Tokener CA in three points.", maxOutputTokens: 512,}); for await (const textPart of result.textStream) { process.stdout.write(textPart);}Next.js Route Handler Example
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";import { streamText } from "ai"; const skypool = createOpenAICompatible({ name: "skypool", baseURL: "https://a.skypool.xyz/v1", apiKey: process.env.SKYPOOL_API_KEY,}); export async function POST(request: Request) { const { messages } = await request.json(); const result = streamText({ model: skypool.chatModel("gemma4:26b"), messages, maxOutputTokens: 1024, }); return result.toUIMessageStreamResponse();}Tool Call Recommendations
The Vercel AI SDK converts tool definitions into model call parameters. When using Tokener CA, we recommend first validating a minimal tool with a model that supports tool calls, and then integrating it into complex workflows.
If you run into structured output or tool call parameter incompatibilities, first confirm:
- Whether the target model supports tool calls
- Whether the request goes through
https://a.skypool.xyz/v1/chat/completions - Whether you are sending provider-specific parameters that the model does not support
Verify with curl First
curl -X POST "https://a.skypool.xyz/v1/chat/completions" \ -H "Authorization: Bearer <consumer_api_key>" \ -H "Content-Type: application/json" \ --data-raw '{ "model": "gemma4:26b", "messages": [ { "role": "user", "content": "Return a short message confirming the integration succeeded." } ], "max_tokens": 64, "stream": false }'Troubleshooting Checklist
| Symptom | How to handle |
|---|---|
| Environment variable is empty | Make sure SKYPOOL_API_KEY is set in .env.local, and restart the dev server |
401 | Check whether the Consumer API Key is valid |
404 | Check whether baseURL is https://a.skypool.xyz/v1 and whether the model ID is correct |
| No output from the streaming endpoint | Verify with the non-streaming generateText first, then switch to streamText |
| Tool call fails | Switch to a model that supports tool calls, and reduce provider-specific parameters |