知识库章节 ▾
导航
▸ 从这里开始 按角色类别
- Cursor + Gonka AI — 便宜的 LLM 用于编码
- Claude Code + Gonka AI — 终端的 LLM
- OpenClaw + Gonka AI — 可负担的 AI 代理
- OpenCode:在终端中使用自己的模型
- Continue.dev + Gonka AI — 适用于 VS Code/JetBrains 的 AI
- Cline + Gonka AI — VS Code 中的 AI 代理
- Aider + Gonka AI — 与 AI 结对编程
- LangChain + Gonka AI — 便宜的 AI 应用程序
- n8n + Gonka AI — 通过便宜的 AI 实现自动化
- Open WebUI + Gonka AI — 您的 ChatGPT
- LibreChat + Gonka AI — 开源 ChatGPT
- Hermes Agent + DeepSeek 在 Gonka 网络 — 极低成本的自主智能体
- Kilo Code + Gonka AI — VS Code 中的 AI 代理
- Roo Code + Gonka AI — VS Code 中的自主 AI 代理
- LlamaIndex + Gonka AI — 低成本的 RAG 应用程序
- PydanticAI + Gonka — 低成本的类型化 AI 代理
- Vercel AI SDK + Gonka AI — 低成本的 TypeScript AI 应用程序
- TanStack AI + Gonka — 低成本的 TypeScript AI 应用程序
- API 快速入门 — curl, Python, TypeScript
- JoinGonka Gateway - 全面概述
- 管理密钥 — Gonka 上的 SaaS
- 最便宜的AI API:2026年提供商对比
- 如何购买AI token和API密钥:2026年的3种方法
- Cursor Pro 请求限制已用尽 — 解析与廉价替代方案
- Claude Code 更便宜 — 账单解析与切换
- Cline 正在烧钱 — 为什么代理花费如此之多
- OpenClaw 成本高昂 —— 为什么 Agent 会疯狂消耗 Token 以及如何节省
- OpenRouter:廉价替代方案 — 与 JoinGonka Gateway 的对比
- 2026 年最佳编码 AI 模型:对比与定价
- GitHub Copilot 无限制低成本替代方案
- 无积分、无限制的廉价 Windsurf 替代方案
- 2026 年最便宜的 AI 代理 API
- ZCode:使用低成本 GLM 推理替代 GLM Coding Plan
- JetBrains IDE + JoinGonka Gateway — 使用自己的 endpoint 替代点数消耗
- GitHub Copilot BYOK — 使用自己的模型替代配额限制
- Zed + JoinGonka Gateway — 编辑器中的低成本推理
- Pi + JoinGonka Gateway — 基于低成本推理的终端代理
- Codex CLI:使用自己的密钥代替订阅
- DeepSeek Harness:通过 JoinGonka Gateway 连接自有提供商
- MiniMax Code:通过 Gonka 使用自备密钥运行 MiniMax 智能体
- Warp + JoinGonka Gateway — 在您端点上的终端代理
- Trae + JoinGonka Gateway — AI-IDE 中的 Gonka 网络模型
- Cherry Studio + JoinGonka Gateway — 桌面 AI 客户端
- omp (Oh My Pi) + JoinGonka Gateway:带模型角色的代理
- OpenHands + JoinGonka Gateway:专属 endpoint 上的智能体
- qwen-oauth 关闭后的 Qwen Code:通过 JoinGonka Gateway 工作
- Goose + JoinGonka Gateway:您的提供商和密钥到 keyring
- Crush + JoinGonka Gateway:基于 Gonka 网络模型的 Charm 代理
- Zoo Code + JoinGonka Gateway:从 Roo Code 迁移至 Gonka 模型
- Kimi Code CLI:通过 Gonka 使用您自己的密钥连接 Moonshot AI Agent
- Factory Droid + JoinGonka Gateway:在 Gonka 网络模型上使用 BYOK
- MiMo Code + JoinGonka Gateway:Gonka 网络模型上的 Xiaomi 代理
工具
LangChain + Gonka AI — 便宜的 AI 应用程序
LangChain 是用于构建 Python 和 JavaScript AI 应用程序的最流行框架。RAG 流水线、链 (chains)、代理 (agents)、文档处理 — LangChain 为这一切提供了抽象。
LangChain 通过 ChatOpenAI 类原生支持 OpenAI 兼容 API。这意味着 JoinGonka Gateway 只需 3 行代码即可集成 — 无需额外的包或配置。
结果:一个 RAG 系统、聊天机器人或 AI 代理,只需 $0.0069/1M token,而不是 OpenAI 的 $2.50-15。
快速入门:3 行代码
最简示例——将 LangChain 连接到 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)就这么简单。三行代码——你的 LangChain 项目就能以极低成本通过去中心化 Gonka 网络运行。
安装依赖:
pip install langchain langchain-openai建议:显式设置 max_tokens=8192——这是通过 JoinGonka Gateway 使用 MiniMax M2.7 和 GLM-5.3 Flash 时的输出上限(DeepSeek V4 Flash 最高可达 32768)。上下文窗口为:MiniMax M2.7 为 200K token(DeepSeek V4 Flash 为 380K,GLM-5.3 Flash 为 390K)——在 RAG 流水线中设置 chunk_size 时请考虑这一点。
示例:使用 Gonka 的 RAG 管道
RAG(Retrieval-Augmented Generation,检索增强生成)是最流行的 AI 应用模式。你加载文档、切分成块、生成嵌入、检索相关片段,并结合上下文生成回答。
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. Load and index 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"])成本:一次 RAG 流水线请求(检索 + 生成)约消耗 2-5K LLM token。通过 Gonka 只需 $0.00001-0.000024。通过 OpenAI 则需 $0.005-0.05。差距高达 1,300 倍。
对于每天处理数千次请求的生产系统,每月可节省数万美元。
示例:带工具调用的 AI 代理
LangChain 让你可以构建带工具(tools)的智能体。网络中的模型支持原生 tool calling——智能体运行可靠,无需解析文本回复。
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:
"""Evaluates a math expression."""
return str(eval(expression))
@tool
def search_web(query: str) -> str:
"""Searches the web for information."""
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"])智能体调用 calculator,获取结果并生成回答。整个循环通过 Gonka 只需约 $0.00005。通过 OpenAI 则需 $0.01-0.05。对于拥有数千用户的系统,这就是数万美元的差距。