推理 API
GenKaKu 提供一个兼容 OpenAI 的 HTTP API——专为代理而建。它支持聊天补全、流式传输、工具/函数调用和模型发现,因此任何与 OpenAI 通信的代理框架只需更改两件事即可工作:base_url 和 api_key。其他无需更改。
base_url: https://genkaku.app/api/v1
为什么在 GenKaKu 上运行你的代理:无审查模型(不会拒绝)、去中心化计算、大上下文,且你的提示词永远不会被存储(在内存中处理并丢弃——只保存令牌计数用于计费)且对工作者匿名(运行你任务的 GPU 只收到提示词文本,永远不会知道你的身份)。参见构建代理了解框架设置。
认证
在 genkaku.app/settings → API 标签页生成 API 密钥。密钥形如 sk-c0mpute-…,创建时显示一次。以 bearer token 形式传递:
Authorization: Bearer sk-c0mpute-...
请求从拥有该密钥的账户的积分余额中扣费。从仪表板使用 USDC 充值。
模型
| 模型 | 描述 |
|---|---|
qwen3.8-27b-uncensored | 无审查的 Qwen3.8 27B,支持工具、视觉和大上下文。网络的模型——也驱动 c0mpute code。 |
qwen3.8-27b-uncensored-think | 相同模型,带扩展链式思考推理。 |
genkaku-pro | 无审查的 Qwen3.5。快速,运行在广泛的浏览器工作者池上。由接取的工作者决定使用 9B 或 4B 回答。 |
genkaku-swarm | MiniMax-M2.5 (229B),由去中心化 GPU 集群服务。可用性取决于集群环是否就绪。 |
GET /v1/models 列出它们并带有实时 available 标志(27B 需要原生 GPU 工作者在线)和 pricing 对象({ "type": "per_token", "usd_per_m_input": 0.15, "usd_per_m_output": 0.90 })。如果你依赖 27B,请始终检查可用性。
旧模型 ID(
supergemma4-26b、code)是已弃用的别名。在迁移窗口期间它们仍会响应,之后将被移除——新集成请指向上述 ID。
定价
计费为按令牌,每个文本模型一个费率表:
| 美元/百万令牌 | |
|---|---|
| 输入 | $0.15 |
| 输出 | $0.90 |
思考令牌是输出令牌,不收取附加费用,因此 qwen3.8-27b-uncensored-think 按令牌计算与基础模型成本相同——只是它通常生成更多令牌。
1 积分 = $0.001,请求向上取整到整数积分,最低 1 积分,因此约 1,200 输入令牌和 600 输出令牌的典型消息成本约 1 积分。积分通过 仪表板 使用 USDC 购买,每美元 500 积分。每个响应包含一个 usage 块,显示你实际被计费的令牌数;流式响应在最后一个块中包含它,当你发送 "stream_options": {"include_usage": true} 时。返回工具调用的请求(代理循环的一步)对其生成的令牌计费。速率限制:每密钥 60 请求/分钟。
因为最终成本只有在回答停止后才知道,请求会放置一个短暂的预扣,金额为其可能的最大成本,未使用的部分在结算时立即退还。余额检查应考虑预扣金额,而非仅典型成本。
套餐和 API 密钥
如果拥有密钥的账户使用套餐,API 请求在动用余额之前先花费该套餐的每日积分。每日积分在 UTC 00:00 重置,不累积。
免费每日积分是例外。它们用于使用应用的用户,因此 API 请求永远不会动用它们,始终从余额中扣费。
余额
GET /v1/balance 返回拥有该密钥的账户的积分余额:
curl https://genkaku.app/api/v1/balance \
-H "Authorization: Bearer $C0MPUTE_API_KEY"
{
"object": "balance",
"credits": 12500,
"usd": 12.50,
"total_deposited": 20000,
"total_spent": 7500
}
用它在一批请求前检查剩余积分,或在集成中显示低余额警告。
图像生成
POST /v1/images/generations——兼容 OpenAI,无审查的图像生成(在贡献者 GPU 上运行 Chroma1-HD)。10 积分($0.01)每张图像。图像以内联 base64 返回,从不存储在服务器端。
curl https://genkaku.app/api/v1/images/generations \
-H "Authorization: Bearer $C0MPUTE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt": "a neon-lit alley in the rain, cinematic", "size": "1024x1024"}'
from openai import OpenAI
client = OpenAI(base_url="https://genkaku.app/api/v1", api_key="sk-c0mpute-...")
img = client.images.generate(prompt="a neon-lit alley in the rain, cinematic", response_format="b64_json")
png_b64 = img.data[0].b64_json
参数:prompt(必需)、size("宽x高",默认 1024x1024)、negative_prompt、seed、nsfw(布尔值,默认 false——SFW 模式运行输出分类器;两种模式都执行绝对安全底线)。n 必须为 1,response_format 必须为 b64_json(无 URL——不存储任何内容)。渲染约需 30 秒;错误使用 OpenAI 格式(402 insufficient_credits、503 当无图像 GPU 可用时)。
聊天补全
POST /v1/chat/completions
curl
curl https://genkaku.app/api/v1/chat/completions \
-H "Authorization: Bearer $C0MPUTE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "genkaku-pro",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(base_url="https://genkaku.app/api/v1", api_key="sk-c0mpute-...")
resp = client.chat.completions.create(
model="genkaku-pro",
messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
Node (OpenAI SDK)
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://genkaku.app/api/v1", apiKey: "sk-c0mpute-..." });
const resp = await client.chat.completions.create({
model: "genkaku-pro",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(resp.choices[0].message.content);
流式传输
设置 stream: true 以接收 Server-Sent Events 作为 chat.completion.chunk 对象,以 data: [DONE] 终止。
stream = client.chat.completions.create(
model="genkaku-pro",
messages=[{"role": "user", "content": "Write a haiku."}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")
函数调用(工具)
传递你自己的 tools。当模型决定调用某个工具时,响应返回 finish_reason: "tool_calls" 和调用内容位于 message.tool_calls 下——你运行工具并将结果作为 tool 消息发回。这使得代理框架能够在 GenKaKu 上驱动自己的工具。
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}]
messages = [{"role": "user", "content": "What's the weather in Paris?"}]
r1 = client.chat.completions.create(model="qwen3.8-27b-uncensored", messages=messages, tools=tools)
call = r1.choices[0].message.tool_calls[0] # get_weather({"city": "Paris"})
messages.append(r1.choices[0].message)
messages.append({"role": "tool", "tool_call_id": call.id, "content": "18C and sunny"})
r2 = client.chat.completions.create(model="qwen3.8-27b-uncensored", messages=messages, tools=tools)
print(r2.choices[0].message.content) # "The weather in Paris is 18°C and sunny."
工具调用和视觉在 qwen3.8-27b-uncensored 上最可靠。浏览器通道可以尝试工具调用但不够稳定。
视觉
qwen3.8-27b-uncensored 接受图像。使用 OpenAI 的多模态内容格式,内联 base64 data: URL:
import base64
img = base64.b64encode(open("photo.png", "rb").read()).decode()
resp = client.chat.completions.create(
model="qwen3.8-27b-uncensored",
messages=[{"role": "user", "content": [
{"type": "text", "text": "What's in this image?"},
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{img}"}},
]}],
)
print(resp.choices[0].message.content)
以内联 base64 形式传递图像;此版本不获取远程 https 图像 URL。视觉需要 qwen3.8-27b-uncensored。仅支持图像输入——创建图像请使用图像生成端点。
构建代理
GenKaKu 被设计为代理框架的大脑。你的框架继续做它的事情——记忆、系统提示词/角色、工具循环——而 GenKaKu 是它调用的模型。记忆和角色无需特殊处理:它们只是你已经发送的消息数组和系统消息。工具通过上述标准函数调用流程工作(模型返回 tool_calls,你的框架运行它们并发送结果回来)。
对于代理,使用 qwen3.8-27b-uncensored(或 qwen3.8-27b-uncensored-think 用于更难的推理)——27B 在多步骤工具使用上远比浏览器通道可靠。
任何兼容 OpenAI 的框架
通用设置:将框架的模型提供商指向 GenKaKu。
base_url / baseURL : https://genkaku.app/api/v1
api_key : sk-c0mpute-...
model : qwen3.8-27b-uncensored
OpenAI Agents SDK (Python)
from agents import Agent, Runner, OpenAIChatCompletionsModel
from openai import AsyncOpenAI
client = AsyncOpenAI(base_url="https://genkaku.app/api/v1", api_key="sk-c0mpute-...")
agent = Agent(name="Assistant", instructions="You are helpful.",
model=OpenAIChatCompletionsModel(model="qwen3.8-27b-uncensored", openai_client=client))
print((await Runner.run(agent, "Plan my week.")).final_output)
LangChain / LangGraph (Python)
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="qwen3.8-27b-uncensored", base_url="https://genkaku.app/api/v1", api_key="sk-c0mpute-...")
Vercel AI SDK (TypeScript)
import { createOpenAI } from "@ai-sdk/openai";
const c0mpute = createOpenAI({ baseURL: "https://genkaku.app/api/v1", apiKey: "sk-c0mpute-..." });
// 使用 c0mpute("qwen3.8-27b-uncensored") 作为 generateText / streamText / 工具循环中的模型
Hermes
GenKaKu 是一个自定义的兼容 OpenAI 端点。对于 Hermes,使用 qwen3.8-27b-uncensored-think(带扩展推理的 27B)。在 ~/.hermes/config.yaml 中将其添加为自定义提供商,API 密钥设置在提供商上(Hermes 在运行时不读取 ~/.hermes/.env,因此密钥必须在配置中或导出的环境变量中):
custom_providers:
- name: c0mpute
base_url: https://genkaku.app/api/v1
api_key: sk-c0mpute-... # 你的密钥,内联
models:
qwen3.8-27b-uncensored-think: {}
不想硬编码密钥?使用 key_env 并在你的 shell 中导出该变量(Hermes 从进程环境读取,而非从 .env):
custom_providers:
- name: c0mpute
base_url: https://genkaku.app/api/v1
key_env: OPENAI_API_KEY # 必须导出,例如在 ~/.bashrc 中
models:
qwen3.8-27b-uncensored-think: {}
然后使用 hermes model(或会话内 /model)选择它,例如 hermes -z "hello" -m qwen3.8-27b-uncensored-think。
如果你看到
HTTP 401: Invalid API key,Hermes 发送的是其no-key-required占位符——它没有找到你的密钥。按上述方式在提供商上设置api_key(仅将密钥放在~/.hermes/.env中不起作用)。
错误
错误以 OpenAI 的格式返回({ "error": { "message", "type", "code" } }):
| 状态码 | 含义 |
|---|---|
401 | 缺少或无效的 API 密钥 |
402 | 积分不足——使用 USDC 充值 |
404 | 未知模型 |
429 | 超出速率限制 |
503 | 没有可用工作者服务所请求的模型(27B 需要原生工作者在线) |
速率限制
默认每密钥 60 请求/分钟。需要更多?联系我们。
图像生成
POST /api/images/generate——生成图像并以内联 base64 数据 URL 形式返回。这是一个 GenKaKu 端点,独立于兼容 OpenAI 的 /v1 接口。认证使用相同的 sk-c0mpute-… bearer 密钥(或已登录的会话)。
请求
| 字段 | 类型 | 默认值 | 备注 |
|---|---|---|---|
prompt | string | — | 必需。 |
negative_prompt | string | — | 可选。始终在基线反伪影负面提示词之上应用。 |
width / height | int | 1024 | 512–1536,取 64 的倍数。 |
steps | int | 32 | 10–60。 |
cfg | number | 4.0 | 引导尺度;Chroma 喜欢约 3.5–4.5。 |
seed | int | 随机 | 可选,用于可重现输出。 |
nsfw | bool | false | 允许成人内容(18+)。关闭时阻止成人输出。 |
响应
{
"image": "data:image/png;base64,...",
"model": "c0mpute-image",
"seed": 31337,
"width": 1024,
"height": 1024,
"credits_charged": 10
}
图像以内联返回,从不存储在服务器端。**10 积分($0.01)**每张图像,失败时自动退款。
错误
400——提示词被内容策略阻止,或 SFW 请求产生了成人输出。402——积分不足。503——当前没有图像工作者在线(请稍后重试)。
curl
curl https://genkaku.app/api/images/generate \
-H "Authorization: Bearer $C0MPUTE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt":"a candid photo of a fox in snow, 35mm film","width":1216,"height":832}'