Knowledge Base Sections ▾
Navigation
▸ Start here By rolesCategories
- Cursor + Gonka AI - cheap LLM for coding
- Claude Code + Gonka AI - LLM for the terminal
- OpenClaw + Gonka AI - affordable AI agents
- OpenCode: your own model in the terminal
- 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
- Hermes Agent + DeepSeek on the Gonka network — an autonomous agent for pennies
- Kilo Code + Gonka AI — AI-Agent in VS Code
- 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
- Cursor Pro request limit reached — breakdown and cheaper alternative
- Claude Code is cheaper — bill breakdown and switching
- Cline is burning money — why the agent spends so much
- OpenClaw is expensive — why the agent burns through tokens and how to save
- OpenRouter: Cheap Alternative — Comparison with JoinGonka Gateway
- 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
- ZCode: Cheap GLM inference instead of GLM Coding Plan
- 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
- Pi + JoinGonka Gateway — terminal agent on cheap inference
- Codex CLI: your own key instead of a subscription
Tools
LangChain + Gonka AI - AI applications for pennies
LangChain is the most popular framework for building AI applications in Python and JavaScript. RAG pipelines, chains, agents, document handling — LangChain provides abstractions for all of this.
LangChain natively supports OpenAI-compatible APIs via the ChatOpenAI class. This means JoinGonka Gateway integrates in 3 lines of code — without additional packages or configuration.
Result: A RAG system, chatbot, or AI agent working for $0.0047/1M tokens instead of $2.50-15 at OpenAI.
Quick Start: 3 lines of code
Minimal example — connecting LangChain to Gonka:
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
base_url="https://gate.joingonka.ai/v1",
api_key="jg-your-key",
model="MiniMaxAI/MiniMax-M2.7",
)
response = llm.invoke("Explain what RAG is")
print(response.content)That is it. Three lines — and your LangChain project runs via the decentralized Gonka network for pennies.
Install dependencies:
pip install langchain langchain-openaiRecommendation: explicitly specify max_tokens=8192 — this is the output limit via JoinGonka Gateway for all network models. The network models' context window is 200K tokens — keep this in mind when configuring chunk_size in RAG pipelines.
Example: RAG pipeline with Gonka
RAG (Retrieval-Augmented Generation) is the most popular pattern for AI applications. You load documents, break them into chunks, create embeddings, search for relevant fragments, and generate an answer with context.
from langchain_openai import ChatOpenAI
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.chains import RetrievalQA
from langchain_community.vectorstores import FAISS
from langchain_community.embeddings import HuggingFaceEmbeddings
from langchain_community.document_loaders import TextLoader
# 1. LLM via Gonka
llm = ChatOpenAI(
base_url="https://gate.joingonka.ai/v1",
api_key="jg-your-key",
model="MiniMaxAI/MiniMax-M2.7",
streaming=True,
)
# 2. Loading and indexing documents
loader = TextLoader("docs/my_document.txt")
docs = loader.load()
splitter = RecursiveCharacterTextSplitter(chunk_size=1000)
chunks = splitter.split_documents(docs)
# 3. Vector store (local, free)
embeddings = HuggingFaceEmbeddings()
vectorstore = FAISS.from_documents(chunks, embeddings)
# 4. RAG chain
qa = RetrievalQA.from_chain_type(
llm=llm,
retriever=vectorstore.as_retriever(),
)
# 5. Query
result = qa.invoke("What is this document about?")
print(result["result"])Cost: one RAG pipeline request (retrieval + generation) uses ~2-5K LLM tokens. Through Gonka, this is $0.00001-0.000024. Through OpenAI, it is $0.005-0.05. The difference is 1,300x.
For production systems processing thousands of requests per day, the savings amount to tens of thousands of dollars per month.
Example: AI agent with tool calling
LangChain allows you to create agents with tools. Kimi K2.6 supports native tool calling — agents work reliably, without parsing text responses.
from langchain_openai import ChatOpenAI
from langchain.agents import create_openai_tools_agent, AgentExecutor
from langchain.tools import tool
from langchain.prompts import ChatPromptTemplate
llm = ChatOpenAI(
base_url="https://gate.joingonka.ai/v1",
api_key="jg-your-key",
model="MiniMaxAI/MiniMax-M2.7",
)
@tool
def calculator(expression: str) -> str:
"""Calculates a mathematical expression."""
return str(eval(expression))
@tool
def search_web(query: str) -> str:
"""Searches for information on the web."""
return f"Search results for: {query}"
prompt = ChatPromptTemplate.from_messages([
("system", "You are a helpful assistant."),
("human", "{input}"),
("placeholder", "{agent_scratchpad}"),
])
agent = create_openai_tools_agent(llm, [calculator, search_web], prompt)
executor = AgentExecutor(agent=agent, tools=[calculator, search_web])
result = executor.invoke({"input": "What is 2**10 * 3.14?"})
print(result["output"])The agent calls calculator, receives the result, and formats the response. The entire cycle costs ~$0.00005 via Gonka. Via OpenAI — $0.01-0.05. For systems with thousands of users, this is a difference of tens of thousands of dollars.