GATEWAY // API DOCUMENTATION

API Documentation

Two protocols, one gateway: Chat Completions and Anthropic Messages. Swap base_url and the API key, and your entire application or coding agent runs unchanged.

cURL Python Node.js Anthropic SDK Cursor Cline
01 / OPENAI Chat Completions Base URL /v1
https://api.velgrind.com/v1

Chat Completions protocol: POST /chat/completions and GET /models. This base URL already includes /v1.

02 / ANTHROPIC Messages API Base URL without /v1
https://velgrind.com

The Anthropic SDK appends /v1/messages itself. If /v1 is written too, the result is /v1/v1/messages → 404. Domain only, without a path.

03 // AUTHENTICATION HEADER Authorization: Bearer <API_KEY> · create a key in the dashboard
04 // MINIMUM CHARGE Rp0.36 per request · real-time balance deduction
01 // AUTHENTICATION & cURL

Every request must include the header Authorization: Bearer vg-....

curl https://api.velgrind.com/v1/chat/completions \
  -H "Authorization: Bearer vg-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "vg/deepseek-v4.1-flash",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
02 // CODING AGENTS & IDEs

Set it up in Cursor, Cline, Roo Code, or OpenCode

Choose provider OpenAI Compatible in your extension or IDE settings, then fill in these three fields:

Base URL: https://api.velgrind.com/v1
API Key: vg-xxxxxxxxxxxxxxxx (from dashboard / community)
Model ID: vg/deepseek-v4.1-flash
Tip: Use vg/deepseek-v4.1-flash for fast & cheap tasks, or vg/claude-opus-4.6 for complex code architecture.
ANTHROPIC-COMPATIBLE

Anthropic Messages protocol

POST /v1/messages POST /v1/messages/count_tokens
ANTHROPIC SDK (Messages API)
from anthropic import Anthropic

# IMPORTANT: base_url WITHOUT /v1. The SDK appends /v1/messages itself.
client = Anthropic(
    base_url="https://velgrind.com",
    api_key="vg-...",
)

m = client.messages.create(
    model="vg/deepseek-v4.1-flash",
    max_tokens=1024,
    system="Jawab ringkas.",
    messages=[{"role": "user", "content": "Explain recursion in 2 sentences"}],
)
print(m.content[0].text)
print(m.usage.input_tokens, m.usage.output_tokens)
The charge is exactly the same as the Chat Completions endpoint for the same prompt — one execution path, two protocol shapes. The velgrind field in the response contains charge_idr and balance_idr (an extra field; SDKs ignore it).
STREAMING (NAMED SSE EVENTS)
with client.messages.stream(
    model="vg/deepseek-v4.1-flash",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Tulis puisi pendek"}],
) as s:
    for teks in s.text_stream:
        print(teks, end="")
    akhir = s.get_final_message()
print(akhir.usage)
Event order: message_start → content_block_start → content_block_delta → content_block_stop → message_delta → message_stop. There is no [DONE] marker like Chat Completions.
TOOL USE
alat = [{
    "name": "cuaca",
    "description": "Cek cuaca sebuah kota",
    "input_schema": {
        "type": "object",
        "properties": {"kota": {"type": "string"}},
        "required": ["kota"],
    },
}]

m = client.messages.create(
    model="vg/deepseek-v4.1-flash",
    max_tokens=512,
    tools=alat,
    messages=[{"role": "user", "content": "Cuaca di Jakarta?"}],
)
for blok in m.content:
    if blok.type == "tool_use":
        print(blok.name, blok.input)
input_schema maps to parameters, and a tool_use is returned as the same block. Tool results are sent back as a tool_result block in the user — the Anthropic shape, not role=tool.
PARAMETER MAPPING

Anthropic → gateway

AnthropicTranslated to
system (str | list)message system at the front
text content blockcontent string
image content blockimage_url (data URL)
tool_usetool_calls[]
tool_resultrole: tool
stop_sequencesstop
max_tokensmax_tokens (default 4096)
tools[].input_schematools[].function.parameters
stop_reasonend_turn · max_tokens · tool_use · stop_sequence
usage.input_tokensprompt_tokens (the same figure as the charge)
Ignored with a warning: top_k, thinking, metadata, container, mcp_servers.
COUNT TOKENS FIRST

count_tokens — free, not billed

r = client.messages.count_tokens(
    model="vg/deepseek-v4.1-flash",
    messages=[{"role": "user", "content": "Hello world"}],
)
print(r.input_tokens)   # 113

The figure includes the persona system prompt the gateway injects, so it matches the real charge — not just the text you send. Use it to measure remaining context before a long request.

This is the same estimator used for context-length validation and the balance check, so there are never two different numbers for one thing.

ANTHROPIC PROTOCOL ERRORS

Shape {"type":"error","error":{...}}

CodetypeMeaning
401authentication_errorWrong key or already revoked
402invalid_request_errorInsufficient balance, or the model price exceeds the key's cap
404not_found_errorUnknown model ID (must start with vg/)
400invalid_request_errorInvalid body, messages empty, or the context is too long
502api_errorUpstream failed on every fallback route
Authentication is checked before the body shape — a wrong key always gets 401, never leaked as a validation error.
03 // PYTHON (SDK)
from openai import OpenAI

client = OpenAI(
    base_url="https://api.velgrind.com/v1",
    api_key="vg-...",
)

r = client.chat.completions.create(
    model="vg/deepseek-v4.1-flash",
    messages=[{"role": "user", "content": "Explain recursion in 2 sentences"}],
)
print(r.choices[0].message.content)
print(r.usage.velgrind)   # {"charge_idr": ..., "balance_idr": ...}
04 // NODE.JS & TYPESCRIPT
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.velgrind.com/v1",
  apiKey: process.env.VELGRIND_KEY,
});

const r = await client.chat.completions.create({
  model: "vg/deepseek-v4.1-flash",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(r.choices[0].message.content);
05 // STREAMING (SERVER-SENT EVENTS)
stream = client.chat.completions.create(
    model="vg/deepseek-v4.1-flash",
    messages=[{"role": "user", "content": "Tulis puisi pendek"}],
    stream=True,
)
for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")
06 // MODEL IDS

Models available (30)

Browse Catalog & Filters →
Model IDNameInput /1M Output /1MContext
vg/sensenova-6.8-flash-pass
SenseNova 6.8 Flash Rp0.00 Rp0.00 1M
vg/mercury-3-pass
Mercury 3 Rp0.00 Rp0.00 1M
vg/luna-pass
GPT-6 Luna Rp0.00 Rp0.00 1,1M
vg/hy4-flash-pass
Hy4 Flash Rp0.00 Rp0.00 960K
vg/deepseek-v4.1-flash-1017-pass
DeepSeek V4.1 Flash 1017 Rp0.00 Rp0.00 1M
vg/kimi-k3-nvfp4-pass
Kimi K3 NVFP4 Rp0.00 Rp0.00 262K
vg/qwen-3-8-27b
Qwen 3.8 27B Rp30.00 Rp270.00 262K
vg/hy3
HY3 Rp140.00 Rp540.00 192K
vg/deepseek-v4.1-flash
DeepSeek 4.1 Flash Rp150.00 Rp610.00 1M
vg/glm-5.3-flash
GLM 5.3 Flash Rp150.00 Rp490.00 1M
vg/minimax-m3.1-flash
MiniMax M3.1 Flash Rp190.00 Rp770.00 1M
vg/deepseek-v4.1-flash-jb
DeepSeek 4.1 Flash JB Rp190.00 Rp650.00 1M
vg/minimax-m3.1-flash-pass
MiniMax M3.1 Flash Rp190.00 Rp770.00 1M
vg/gpt-6-luna
GPT-6 Luna Rp260.00 Rp1,270.00 272K
vg/kimi-k2.5
Kimi K2.5 Rp690.00 Rp3,420.00 164K
vg/hy4-preview
HY4 Preview Rp730.00 Rp2,200.00 1M
vg/glm-5.3
GLM 5.3 Rp800.00 Rp2,520.00 1M
vg/qwen-3.8-omni-flash
Qwen 3.8 Omni Flash Rp1,090.00 Rp3,410.00 1M
vg/glm-5.4
GLM 5.4 Rp1,190.00 Rp3,750.00 1M
vg/claude-haiku-5.5
Claude Haiku 5.5 Rp1,840.00 Rp9,190.00 1M
vg/gemini-3.8-flash-high
Gemini 3.8 Flash High Rp1,880.00 Rp9,410.00 1M
vg/kimi-k3
Kimi K3 Rp2,340.00 Rp11,690.00 1M
vg/deepseek-v4.1-flash-uncensored
DeepSeek 4.1 Flash Uncensored Rp2,390.00 Rp10,440.00 1M
vg/claude-sonnet-5.5
Claude Sonnet 5.5 Rp3,960.00 Rp19,780.00 1M
vg/deepseek-v4-pro-0813
DeepSeek V4 Pro 0813 Rp4,130.00 Rp12,370.00 1M
vg/kimi-k3.1-pro
Kimi K3.1 Pro Rp10,360.00 Rp51,760.00 1M
vg/claude-sonnet-4.6
Claude Sonnet 4.6 Rp12,560.00 Rp62,820.00 1M
vg/qwen4-max
Qwen4 Max Rp12,660.00 Rp37,960.00 1M
vg/claude-opus-4.6
Claude Opus 4.6 Rp15,900.00 Rp79,520.00 1M
vg/claude-opus-5.5
Claude Opus 5.5 Rp19,950.00 Rp99,730.00 1M
07 // BILLING MECHANICS

Billing & Balance

The charge is calculated from prompt_tokens + completion_tokens reported by upstream. Cached input tokens are billed at that model's cache-hit rate — which differs per model and always matches the Cache hit / 1M di Models & pricing. No parameter needs to be sent to get this rate. Minimum charge Rp0.36 per request — even the smallest request pays this to cover the gateway's fixed cost.

The balance is deducted after the response completes. If it cannot cover the estimate estimate, the request is rejected with 402 before it is sent to the model.

Per-key price cap. Catalog prices follow provider cost, so each key can carry its own cap in the dashboard (the Price Cap, Rupiah per 1 million input tokens). Requests to a model priced above the cap is rejected with 402 price_limit_exceeded before the balance is touched — not partially charged. Leave empty for no cap.

There is no active period. As long as there is balance, the API key works — no expiry date and no monthly fee. Unused balance stays on your account until you spend it. The only things that stop a key: balance running out 402 or the account being suspended by the admin 401.

08 // HTTP STATUS CODES

Standard Error Codes

CodeMeaning & Handling
401Wrong key or already revoked
402Rupiah balance is not enough to process the request
404Model ID not found (make sure it starts with vg/)
502Upstream did not respond on any fallback route