Knowledge Base Sections ▾
Navigation
▸ Start here By rolesCategories
- OpenCode: free models, providers and API key
- Cursor + Gonka AI - cheap LLM for coding
- Claude Code + Gonka AI - LLM for the terminal
- DeepSeek Harness: Your Own Provider via JoinGonka Gateway
- Codex CLI: your own key instead of a subscription
- Pi + JoinGonka Gateway — terminal agent on cheap inference
- omp (Oh My Pi) + JoinGonka Gateway: an agent with model roles
- Zoo Code + JoinGonka Gateway: Migrating from Roo Code to Gonka models
- Kilo Code + Gonka AI — AI-Agent in VS Code
- ZCode: GLM Coding Plan tiers, prices and limits
- Hermes Agent + DeepSeek on the Gonka network — an autonomous agent for pennies
- OpenClaw + Gonka AI - affordable AI agents
- Continue.dev + Gonka AI - AI for VS Code/JetBrains
- Cline + Gonka AI - AI agent in VS Code
- Aider + Gonka AI - pair programming with AI
- LangChain + Gonka AI - AI applications for pennies
- n8n + Gonka AI - automation with cheap AI
- Open WebUI + Gonka AI - your own ChatGPT
- LibreChat + Gonka AI — open-source ChatGPT
- Roo Code + Gonka AI — Autonomous AI Agent in VS Code
- LlamaIndex + Gonka AI — RAG applications for pennies
- PydanticAI + Gonka — typed AI agents for pennies
- Vercel AI SDK + Gonka AI — AI applications in TypeScript for pennies
- TanStack AI + Gonka — AI applications in TypeScript for pennies
- API quick start — curl, Python, TypeScript
- JoinGonka Gateway — a full overview
- Management Keys — SaaS on Gonka
- Cheapest AI API: Provider Comparison 2026
- How to buy AI tokens and an API key: 3 methods in 2026
- Free AI API: tokens on sign-up and for referrals
- Cursor Pro request limit reached — breakdown and cheaper alternative
- Cheaper Claude Code: GLM and DeepSeek instead of Claude
- Claude Code + DeepSeek V4 Flash: How to Connect It and What a Task Costs
- Cline is burning money — why the agent spends so much
- OpenClaw is expensive — why the agent burns through tokens and how to save
- OpenRouter alternative: the same models, many times cheaper
- Best AI model for coding in 2026: comparison and prices
- Cheap alternative to GitHub Copilot without limits
- A cheap Windsurf alternative without credits or limits
- The cheapest API for AI agents in 2026
- JetBrains IDE + JoinGonka Gateway — your own endpoint instead of credits
- GitHub Copilot BYOK — own models instead of quotas
- Zed + JoinGonka Gateway — cheap inference in your editor
- MiniMax Code: MiniMax agent with your own key via Gonka
- Warp + JoinGonka Gateway — terminal agent on your own endpoint
- Trae + JoinGonka Gateway — Gonka network models in AI-IDE
- Cherry Studio + JoinGonka Gateway — desktop AI client
- OpenHands + JoinGonka Gateway: agent on your own endpoint
- Qwen Code after the closure of qwen-oauth: working via JoinGonka Gateway
- Goose + JoinGonka Gateway: your own provider and key in the keyring
- Crush + JoinGonka Gateway: Charm agent on Gonka network models
- Kimi Code CLI: Moonshot AI agent on your key via Gonka
- Factory Droid + JoinGonka Gateway: BYOK on Gonka network models
- MiMo Code + JoinGonka Gateway: Xiaomi agent on Gonka network models
Tools
Vercel AI SDK + Gonka AI — AI applications in TypeScript for pennies
Vercel AI SDK is the most popular SDK for building AI applications in TypeScript and JavaScript. A unified generateText and streamText API, streaming to UI, native tool calling, and built-in helpers for Next.js App Router — everything you need for chatbots, agents, and RAG pipelines on the web.
The problem is the same as with any LLM application — the provider cost. A streaming chat interface sends the dialogue history with every message, and an agent cycles context through dozens of steps. At Anthropic ($3-15/1M) and OpenAI ($2.5-10/1M) prices, even a modest pet project in production turns into a bill for hundreds of dollars a month.
JoinGonka Gateway is an OpenAI-compatible endpoint over the decentralized Gonka network. Vercel AI SDK connects to it like any OpenAI-compatible provider — no forks, no custom adapters. The same open models as with commercial hosts — MiniMax M2.7, DeepSeek V4 Flash, and GLM-5.3 Flash — the same streamText, but at $0.0062/1M input tokens — tens of times cheaper.
Step 1: Get a key and connect the provider
JoinGonka API key: sign up at gate.joingonka.ai/register — to get you started we're giving away 3M free tokens. In the Dashboard, create a key with the jg- prefix.
Installing packages. For a custom OpenAI-compatible endpoint, the Vercel AI SDK recommends the @ai-sdk/openai-compatible provider:
npm install ai @ai-sdk/openai-compatibleMinimal setup — create a provider instance with createOpenAICompatible and call generateText:
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { generateText } from 'ai';
const gonka = createOpenAICompatible({
name: 'gonka',
baseURL: 'https://gate.joingonka.ai/v1',
apiKey: process.env.GONKA_API_KEY, // jg-your-key
});
const { text } = await generateText({
model: gonka('MiniMaxAI/MiniMax-M2.7'),
prompt: 'Explain what a decentralized inference network is',
});
console.log(text);The apiKey parameter automatically adds the Authorization: Bearer jg-your-key header — no separate configuration needed. Keep the key in the GONKA_API_KEY environment variable (for example, in .env.local), not in your code.
Alternative — the @ai-sdk/openai package with the createOpenAI({ baseURL, apiKey }) factory. Both approaches work; for endpoints that don't belong to OpenAI, the AI SDK documentation specifically recommends @ai-sdk/openai-compatible — it doesn't drag in extra OpenAI-specific assumptions.
Step 2: Streaming and Next.js route handler
The main highlight of the Vercel AI SDK is streaming responses. The streamText function starts streaming tokens immediately, and the toUIMessageStreamResponse() helper returns a ready-made stream straight from a route handler in the Next.js App Router.
Server handler app/api/chat/route.ts:
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { streamText, convertToModelMessages, type UIMessage } from 'ai';
const gonka = createOpenAICompatible({
name: 'gonka',
baseURL: 'https://gate.joingonka.ai/v1',
apiKey: process.env.GONKA_API_KEY,
});
// allow streaming for up to 30 seconds
export const maxDuration = 30;
export async function POST(req: Request) {
const { messages }: { messages: UIMessage[] } = await req.json();
const result = streamText({
model: gonka('MiniMaxAI/MiniMax-M2.7'),
system: 'You are a helpful assistant. Answer briefly and to the point.',
messages: convertToModelMessages(messages),
maxOutputTokens: 8192, // Gateway output cap
});
return result.toUIMessageStreamResponse();
}On the client, wire up the useChat hook from @ai-sdk/react — it talks to /api/chat on its own and renders the message stream. Meanwhile, the backend talks to Gonka instead of OpenAI.
Script without a UI (Node, async iterator over the stream):
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { streamText } from 'ai';
const gonka = createOpenAICompatible({
name: 'gonka',
baseURL: 'https://gate.joingonka.ai/v1',
apiKey: process.env.GONKA_API_KEY,
});
const result = streamText({
model: gonka('MiniMaxAI/MiniMax-M2.7'),
prompt: 'Write a haiku about distributed computing',
});
for await (const chunk of result.textStream) {
process.stdout.write(chunk);
}Model parameters. Three models are available through the Gateway: 180K token context for MiniMax M2.7, 380K for DeepSeek V4 Flash, and 390K for GLM-5.3 Flash; the response ceiling (maxOutputTokens) is 8192 for MiniMax M2.7 and GLM-5.3 Flash, and 32768 for DeepSeek V4 Flash:
MiniMaxAI/MiniMax-M2.7— the default (MiniMax M2.7);deepseek-ai/DeepSeek-V4-Flash-0731(DeepSeek V4 Flash, 380K context);zai-org/GLM-5.3-Flash(GLM-5.3 Flash, a reasoning model — it thinks before it answers).
If maxOutputTokens isn't set, the Gateway returns up to 1500 tokens by default for a non-stream request — for streaming chats, it's best to specify the value explicitly.
Cost Comparison
The Vercel AI SDK typically sits behind an interactive interface — chat, agent, or in-app assistant. Each message carries the dialogue history, and each agent step carries tool context. Therefore, the actual cost is calculated not by a single request, but by the production load. Let's compare typical scenarios:
| Scenario | Tokens | Anthropic / OpenAI | JoinGonka Gonka |
|---|---|---|---|
| One chat message | ~3K | $0.01 — $0.05 | $0.000028 |
| 20-turn dialogue | ~150K | $0.50 — $2.25 | $0.0014 |
| RAG-response (search + generation) | ~5K | $0.015 — $0.05 | $0.000048 |
| Agent step with tool calling | ~10K | $0.03 — $0.10 | $0.000096 |
| 10,000 requests per day (prod) | ~50M | $150 — $500 | $0.48 |
The JoinGonka price is about $0.0062 per 1M input tokens, with output being roughly three times more expensive. For an application with thousands of requests per day, this is the difference between a bill of hundreds of dollars and a bill of mere cents. The free 3M tokens are enough to run your project's first requests.
Tool calling and agents
The Vercel AI SDK describes tools declaratively through a tools object and a zod schema. The network's models support native function calling, so the AI SDK receives structured tool_calls without parsing text responses. The stopWhen: stepCountIs(n) parameter allows several steps in a row — the model calls a tool, gets the result, and continues.
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { generateText, tool, stepCountIs } from 'ai';
import { z } from 'zod';
const gonka = createOpenAICompatible({
name: 'gonka',
baseURL: 'https://gate.joingonka.ai/v1',
apiKey: process.env.GONKA_API_KEY,
});
const { text } = await generateText({
model: gonka('MiniMaxAI/MiniMax-M2.7'),
stopWhen: stepCountIs(5),
tools: {
weather: tool({
description: 'Get the weather in a city',
inputSchema: z.object({ city: z.string() }),
execute: async ({ city }) => ({ city, tempC: 17 }),
}),
},
prompt: 'What is the weather in Moscow? Answer in one sentence.',
});
console.log(text);The model calls the weather tool, gets the result, and forms the final answer. The whole cycle costs about $0.000048 through Gonka versus $0.03-0.10 with Anthropic or OpenAI. For agentic applications where every user request unfolds into 5-10 steps, the production savings add up to thousands of dollars a month.
If you're building an AI application in Python, check out the LangChain guide — it takes the same approach through the OpenAI-compatible class.