GenOnServing

API Documentation

OpenAI-compatible API. Base URL: https://api.genon.ai/v1

Quick Start — Chat

Endpoint: https://api.genon.ai/v1/chat/completions · Model: anthropic/claude-opus-5

curl
curl https://api.genon.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-svp-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-opus-5",
    "messages": [{"role":"user","content":"Hello"}],
    "thinking_token_budget": 2048
  }'
Python
OpenAI SDK
from openai import OpenAI
client = OpenAI(api_key="sk-svp-YOUR_KEY", base_url="https://api.genon.ai/v1")
r = client.chat.completions.create(
    model="anthropic/claude-opus-5",
    messages=[{"role": "user", "content": "Hello"}],
    extra_body={"thinking_token_budget": 2048},  # reasoning cap — honored by e.g. Qwen3
)
print(r.choices[0].message.content)
JavaScript
openai npm
import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk-svp-YOUR_KEY", baseURL: "https://api.genon.ai/v1" });
const r = await client.chat.completions.create({
    model: "anthropic/claude-opus-5",
    messages: [{ role: "user", content: "Hello" }],
    // @ts-expect-error non-standard field (ours): reasoning cap — honored by e.g. Qwen3
    thinking_token_budget: 2048,
});
console.log(r.choices[0].message.content);
Response
예시 출력
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "model": "anthropic/claude-opus-5",
  "choices": [
    { "index": 0, "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "...",
        "reasoning_content": "..."   // reasoning 모델만 (예: Qwen3/GLM)
      }
    }
  ],
  "usage": { "prompt_tokens": 12, "completion_tokens": 48, "total_tokens": 60 }
}
// stream=true → SSE chat.completion.chunk delta 시퀀스.
Available Models
ModelTypeContextInput / 1MOutput / 1M$/image
openai/gpt-5.6-sol
Chat
1,048,576$5.00$30.00
openai/gpt-5.6-terra
Chat
1,048,576$2.50$15.00
openai/gpt-5.5
Chat
1,048,576$5.00$30.00
minimaxai/minimax-m3
Chat
1,048,576$0.30$1.20
google/gemma-4-26b-a4b-it
Chat
262,144$0.07$0.34
meta/muse-spark-1.3-contributor
Chat
1,048,576$0.10$0.20
openai/gpt-5.6-luna
Chat
1,050,000$0.20$1.20
openai/whisper-large-v3
Speech to text
$0.0060 / audio min
boogu/boogu-image-0.1-base
Image generation
$0.020
boogu/boogu-image-0.1-edit
Image edit
$0.040
baai/bge-m3
Embedding
8,192$0.01
z-ai/glm-5.3-flash
Chat
1,310,720$0.07$0.25
anthropic/claude-opus-5
Chat
1,000,000$5.00$25.00
qwen/qwen3.8-flash
Chat
1,000,000$0.16$0.47
qwen/qwen3.8-27b
Chat
1,000,000$0.42$2.55
qwen/qwen3.6-35b-a3b
Chat
262,144$0.14$1.00
zai-org/glm-5.2
Chat
1,048,576$1.19$3.74
moonshotai/kimi-k2.6
Chat
262,144$0.95$4.00
qwen/qwen3.5-397b-a17b-fp8
Chat
262,144$0.50$3.60
minimax/minimax-m3
Chat
1,048,576$0.30$1.20
microsoft/phi-4
Chat
16,384$0.07$0.14
openai/gpt-oss-20b
Chat
131,072$0.03$0.13
Account & Billing API

OpenRouter-compatible introspection endpoints. Both /v1/* and /api/v1/* prefixes work.

GET /v1/auth/key
key info

Returns the calling key's label, monthly usage, budget cap, remaining credit, and rate limit. Mirrors OpenRouter's key-introspection shape.

curl https://api.genon.ai/v1/auth/key -H "Authorization: Bearer sk-svp-YOUR_KEY"

# 200 OK
{
  "data": {
    "label": "prod-bot",
    "usage": 12.34,             # USD spent this month
    "limit": 50.0,              # USD cap (null if inherited)
    "limit_remaining": 37.66,   # org credit balance, USD
    "is_free_tier": false,
    "is_provisioning_key": false,
    "rate_limit": { "requests": 60, "interval": "1m" }
  }
}
GET /v1/credits
balance

Org-level credit balance and total usage. Use for dashboards that don't need per-key detail.

curl https://api.genon.ai/v1/credits -H "Authorization: Bearer sk-svp-YOUR_KEY"

# 200 OK
{ "data": { "total_credits": 999.50, "total_usage": 12.34 } }
GET /v1/generation?id=<request_id>
post-hoc lookup

After a streamed completion, fetch the final token counts, cost, and latency by the request_id returned in the x-request-id response header. Requires your API key, and only returns generations belonging to your organisation. The billing row is written asynchronously, so a just-finished request may 404 for a few seconds.

curl "https://api.genon.ai/v1/generation?id=01HFAKEULID01" \
  -H "Authorization: Bearer $GENON_API_KEY"

# 200 OK
{
  "data": {
    "id": "gen-01HFAKEULID01",
    "request_id": "01HFAKEULID01",
    "model": "google/gemma-4-26b-a4b-it",
    "created_at": "2026-07-30T03:28:47.519000+00:00",
    "provider_name": "genon-nhn",
    "tokens_prompt": 1000,
    "tokens_completion": 500,
    "native_tokens_cached": 0,
    "total_cost": 0.000295,            # USD dollars, not cents
    "usage": 0.000295,
    "latency": 2300,                   # ms
    "generation_time": 2300,
    "status": "ok"
  }
}

total_cost is USD dollars — here 1000 input + 500 output tokens at gemma-4's $0.12/$0.35 per 1M.

usage.cost
on every chat completion response

Non-streaming /v1/chat/completions responses now include usage.cost (USD float). Tools like Aider and Continue render this directly without an extra /generation round-trip.

{
  "id": "chatcmpl-...",
  "choices": [...],
  "usage": {
    "prompt_tokens": 1000,
    "completion_tokens": 500,
    "total_tokens": 1500,
    "prompt_tokens_details": { "cached_tokens": 0 },
    "cost": 0.000750                    # USD, computed from per-model pricing
  },
  "provider": "genon-nhn"
}
Streaming (Server-Sent Events)

Set stream: true on /v1/chat/completions to receive incremental tokens. Each SSE frame is a JSON delta; the last frame before [DONE] contains the final usage block when stream_options.include_usage: true.

# Python
from openai import OpenAI
client = OpenAI(api_key="sk-svp-...", base_url="https://api.genon.ai/v1")
stream = client.chat.completions.create(
    model="zai-org/glm-5.2",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True,
    stream_options={"include_usage": True},
)
for chunk in stream:
    delta = chunk.choices[0].delta.content if chunk.choices else None
    if delta:
        print(delta, end="", flush=True)
    if chunk.usage:
        print(f"\ntokens: in={chunk.usage.prompt_tokens} out={chunk.usage.completion_tokens}")
Tool / Function Calling

All chat models advertise the tools feature. Pass an OpenAI-style tools array and tool_choice ("auto" / "required" / {type:"function",function:{name}}). The selected model picks tools and emits tool_calls[] in choices[0].message; reply with a role:"tool" message to feed execution results back.

r = client.chat.completions.create(
    model="zai-org/glm-5.2",
    messages=[{"role": "user", "content": "What's the weather in Seoul?"}],
    tools=[{
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get current weather for a location",
            "parameters": {
                "type": "object",
                "properties": {"location": {"type": "string"}},
                "required": ["location"],
            },
        },
    }],
    tool_choice="auto",
)
call = r.choices[0].message.tool_calls[0]
print(call.function.name, call.function.arguments)
Reasoning content (thinking)

GLM-5.2, Qwen3.5, and Kimi-K2.6 emit chain-of-thought tokens separately as message.reasoning_content (and mirrored under provider_specific_fields.reasoning). They are billed as completion tokens. Toggle thinking off via chat_template_kwargs when the model accepts it (Kimi-K2.6 supported, qwen3.5 ignores the flag).

r = client.chat.completions.create(
    model="moonshotai/kimi-k2.6",
    messages=[{"role": "user", "content": "Explain prime factorisation"}],
    extra_body={"chat_template_kwargs": {"thinking": False}},
)
msg = r.choices[0].message
print("answer:", msg.content)
print("thinking:", msg.reasoning_content)  # may be None when disabled
Multimodal (vision)

qwen/qwen3.5-397b-a17b-fp8 accepts text + image input. Send the OpenAI multimodal content array; image URLs may be http(s):// or data:image/...;base64,....

r = client.chat.completions.create(
    model="qwen/qwen3.5-397b-a17b-fp8",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "What's in this image?"},
            {"type": "image_url", "image_url": {"url": "https://example.com/cat.png"}},
        ],
    }],
)
print(r.choices[0].message.content)
Third-party SDKs

The serving API is OpenAI-compatible — point any OpenAI SDK at our base URL.

LangChain
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
    model="zai-org/glm-5.2",
    openai_api_key="sk-svp-...",
    openai_api_base="https://api.genon.ai/v1",
)
print(llm.invoke("hi"))
Continue / Cline / Cursor
{
  "models": [{
    "title": "GenOn GLM-5.2",
    "provider": "openai",
    "model": "zai-org/glm-5.2",
    "apiBase": "https://api.genon.ai/v1",
    "apiKey": "sk-svp-..."
  }]
}
Aider
OPENAI_API_BASE=https://api.genon.ai/v1 \
OPENAI_API_KEY=sk-svp-... \
aider --model openai/zai-org/glm-5.2

Aider reads usage.cost from each completion to render running spend — populated for all our chat models since #135.

Anthropic SDK
# Both /v1/messages and /v1/chat/completions work — see the Chat tab above
# for the Anthropic shape (#123/#147).
Error Codes
402
insufficient_creditsTop up at Credits page
429
rate_limitedReduce RPM or contact us
404
model_not_foundCheck /v1/models for available models
400
context_length_exceededReduce input length
422
invalid_sizeImage size must be one of the supported presets