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
TanStack AI + Gonka — AI applications in TypeScript for pennies
TanStack AI (@tanstack/ai) is a type-safe SDK for TypeScript from the TanStack team (creators of Query, Router, Table). Provider-agnostic architecture: streaming chat, native tool calling, agents, structured output, and multimodality through a single set of adapters. Ready-to-use bindings for React, Vue, Svelte, Solid, and Preact (useChat and other hooks) plus a headless client for the server.
The problem is the same as with any AI framework: inference cost. TanStack AI supports OpenAI, Anthropic, and Gemini out of the box, but these providers' direct rates ($2.50–15 per 1M tokens) make production chats and agents expensive: streaming dialogs and tool-cycles quickly consume millions of tokens.
A key feature of TanStack AI is the openaiCompatible() function: a first-class way to connect any OpenAI-compatible endpoint. This means JoinGonka Gateway integrates without custom adapters—just specify the baseURL, key, and model list. The result: the same type-safe chat and agents, but at $0.0062/1M tokens via the decentralized Gonka network instead of $2.50–15 at OpenAI.
Step 1: Install TanStack AI and get a key
Package installation (core + OpenAI-adapter, where openaiCompatible lives):
# pnpm
pnpm add @tanstack/ai @tanstack/ai-openai
# npm
npm install @tanstack/ai @tanstack/ai-openaiFor a React chat interface, add the client and hooks:
pnpm add @tanstack/ai-client @tanstack/ai-reactJoinGonka API key: if you don't have one yet — register at gate.joingonka.ai/register, get 3M free tokens and create a jg-xxx key in Dashboard → API Keys. One key and one balance work for both OpenAI and Anthropic formats.
Step 2: Connect Gonka via openaiCompatible
In TanStack AI, a custom OpenAI-compatible provider is configured with the openaiCompatible() function: you set baseURL, apiKey, and a list of models once, then pick a model for each call. Our Gateway speaks the Chat Completions format, so we leave api: 'chat-completions' (this is the default value).
import { openaiCompatible } from '@tanstack/ai-openai'
// Gonka provider: configured once
export const gonka = openaiCompatible({
name: 'gonka',
baseURL: 'https://gate.joingonka.ai/v1',
apiKey: process.env.GONKA_API_KEY!, // jg-your-key
api: 'chat-completions',
models: [
'MiniMaxAI/MiniMax-M2.7', // default
'deepseek-ai/DeepSeek-V4-Flash-0731',
'zai-org/GLM-5.3-Flash', // reasoning model
],
})Streaming chat on the server (for example, a route handler in any fullstack framework or TanStack Start). We set the response length via modelOptions — this is the only place for native wire parameters (max_tokens, temperature):
import { chat, toServerSentEventsResponse } from '@tanstack/ai'
import { gonka } from './gonka'
export async function POST(request: Request) {
const { messages } = await request.json()
const stream = chat({
adapter: gonka('MiniMaxAI/MiniMax-M2.7'),
messages,
modelOptions: { max_tokens: 8192 }, // Gateway output cap
})
return toServerSentEventsResponse(stream)
}React client via the useChat hook — streams responses from the server into the UI:
import { useChat } from '@tanstack/ai-react'
function Chat() {
const { messages, sendMessage, status } = useChat({ api: '/api/chat' })
return (
<div>
{messages.map((m) => (
<p key={m.id}><b>{m.role}:</b> {m.content}</p>
))}
<button onClick={() => sendMessage('What is Gonka?')}>
Ask
</button>
</div>
)
}Without a server: the same provider works directly in a script or backend — call chat() and read the stream. Connecting to Gonka is identical for all options.
Model parameters via the Gateway: the context is 180K tokens for MiniMax M2.7, 380K for DeepSeek V4 Flash, and 390K for GLM-5.3 Flash. The max_tokens ceiling is 8192 for MiniMax M2.7 and GLM-5.3 Flash, 32768 for DeepSeek V4 Flash. If max_tokens is not specified, the default for non-stream is 1500, so for long responses set it explicitly.
Cost Comparison
TanStack AI works equally well through direct OpenAI/Anthropic rates or via Gonka—only the baseURL changes. But the cost differs by orders of magnitude. Let’s compare typical production loads for a TanStack AI application:
| Scenario | Tokens | OpenAI / Anthropic | JoinGonka Gonka |
|---|---|---|---|
| One streaming chat response | ~3K | $0.008 — $0.045 | $0.000028 |
| Agent cycle with tool calling | ~15K | $0.04 — $0.22 | $0.00014 |
| 1,000 dialogues per day | ~3M | $7.50 — $45 | $0.028 |
| Production month (~100M) | ~100M | $250 — $1,500 | $0.96 |
TanStack AI’s provider-agnostic approach means switching to Gonka is just a one-line change (baseURL), not a code rewrite. Meanwhile, your type-safe tools, structured output, and React hooks remain unchanged. For an application with thousands of users, the difference is tens of thousands of dollars per month.
Gonka pricing: input ~$0.0062 per 1M tokens, output ×3. This is hundreds to thousands of times cheaper than the direct rates of OpenAI and Anthropic.
Type-safe tools and model selection
The main feature of TanStack AI is a single contract, toolDefinition(): you describe a tool once (input/output via Zod, ArkType, Valibot, or JSON Schema), and the implementation is bound on the server or the client. MiniMax M2.7, DeepSeek V4 Flash, and GLM-5.3 Flash support native tool calling through Gonka, so agents run reliably — no parsing of text responses required.
import { chat, toolDefinition } from '@tanstack/ai'
import { gonka } from './gonka'
import { z } from 'zod'
const getWeather = toolDefinition({
name: 'getWeather',
description: 'Get the weather in a city',
inputSchema: z.object({ city: z.string() }),
outputSchema: z.object({ tempC: z.number() }),
}).server(async ({ city }) => {
return { tempC: 21 } // your real API call
})
const stream = chat({
adapter: gonka('MiniMaxAI/MiniMax-M2.7'),
messages: [{ role: 'user', content: 'What is the weather in Moscow?' }],
tools: [getWeather],
modelOptions: { max_tokens: 8192 },
})Which model to pick:
- MiniMaxAI/MiniMax-M2.7 — the default: a balance of speed and quality, with a long context. Response ceiling: 8192.
- deepseek-ai/DeepSeek-V4-Flash-0731 — one of the longest contexts on the network (380K), cheap for large prompts. Response ceiling: 32768.
- zai-org/GLM-5.3-Flash — a reasoning model: it thinks before answering and excels at complex logic; the longest context on the network (390K). Response ceiling: 8192; reasoning consumes part of
max_tokens.
Thanks to runtime adapter switching in TanStack AI, you can keep all three models under one provider and switch between them on the fly — for example, reasoning tasks on GLM-5.3 Flash and quick answers on MiniMax.