1 Get an API key in Telegram
Manage your account and API keys in Telegram; review purchases and request activity from the dashboard.
Open @tokoapikey_bot and send /start. Your account is created automatically.
Use /buy in Telegram, choose a product, then pay by QRIS or USDT. Wallet credit is added after payment is confirmed.
Open the API Key menu in Telegram and create a key. Its plaintext is shown only once.
How billing works. Before forwarding, the gateway checks access and estimates cost. It records valid usage and debits available funds. Without an output limit, it uses 512 tokens.
Two API key types. Pay-as-you-go keys are created by you (up to 5 active keys) and work with public models. Plan keys are issued automatically after a plan purchase is paid. Access follows the plan allowlist; an empty allowlist follows the catalog's public-model rules. Models marked plan access in the catalog require a plan key that includes them. Wallet balances are shared across your keys. PAYG products can add USD credit or token balance.
2 Send your first request
Send a first request with a low output limit. This lets the gateway estimate the required balance before forwarding it.
Copy the command and replace <API_KEY_FROM_TELEGRAM> and the model ID
(choose one from the model catalog):
curl https://api.leuwongrr.cloud/v1/chat/completions \
-H "Authorization: Bearer <API_KEY_FROM_TELEGRAM>" \
-H "Content-Type: application/json" \
-d '{"model":"<MODEL_ID>","max_tokens":4096,"messages":[{"role":"user","content":"Hello"}]}'Why set an output limit? The gateway estimates cost from the request size and maximum output. If the request omits a limit, the gateway uses a safe default of 512 tokens. The example's 4096 is a request-level limit, not a server-wide cap. Increase it when needed; insufficient funds return 402 before the conversation is sent upstream.
The lrr/ prefix is optional. Clients that add it automatically are supported:
lrr/<model> and lrr/lrr/<model> resolve to the same model. Model IDs are case-insensitive.
Never paste a real API key into a public place. The example uses a placeholder.
3 Configure your client
Use the configuration for your client. The base URL and authentication header depend on the API format.
Claude Code (Anthropic)
export ANTHROPIC_BASE_URL="https://api.leuwongrr.cloud"
export ANTHROPIC_AUTH_TOKEN="<API-KEY-DARI-BOT>"
claudeCodex CLI (OpenAI-compatible)
export OPENAI_BASE_URL="https://api.leuwongrr.cloud/v1"
export OPENAI_API_KEY="<API-KEY-DARI-BOT>"
codexzcode
export OPENAI_BASE_URL="https://api.leuwongrr.cloud/v1"
export OPENAI_API_KEY="<API-KEY-DARI-BOT>"
# atau lewat config provider custom — base URL samaCursor · Cline · VS Code extensions
In your provider settings, set API Key to <API_KEY> from Telegram, Base URL to
https://api.leuwongrr.cloud/v1, and Model to an ID from the model catalog.
Anthropic SDK (Python)
import anthropic
client = anthropic.Anthropic(
base_url="https://api.leuwongrr.cloud",
api_key="<API-KEY-DARI-BOT>",
)4 Endpoints
All supported API formats use the same model catalog and wallet. Only the request path differs.
| Endpoint | Description |
|---|---|
GET/v1/ | List available models in the OpenAI format. |
POST/v1/ | OpenAI Chat Completions: tools, structured output, streaming. |
POST/v1/ | OpenAI Responses: tools, reasoning, structured output, streaming. |
POST/v1/ | Anthropic Messages: tools, thinking, streaming. |
Authentication
| Client | Header |
|---|---|
| OpenAI | Authorization: Bearer <API-KEY> |
| Anthropic | x-api-key: <API-KEY> |
Chat Completions streaming requests include stream_options.include_usage. Responses and Messages use the provider's native usage fields. If valid usage is missing, settlement is rejected rather than guessed.
5 Error reference
Use the status and error code to choose the next step. The gateway only bills valid usage reported by the provider.
| Code | Next step |
|---|---|
401 invalid_api_keyThe key is invalid or has been revoked | Create a new key in Telegram under API Key |
402 insufficient_fundsThe selected wallet balance is too low | Add credit from the product catalog or Telegram bot |
422 max_tokens_requiredThe output-limit field is not a valid number | Correct max_tokens, max_completion_tokens, or max_output_tokens. If omitted, the gateway uses 512. |
403 model_not_in_planThe model is not included in this plan key's allowlist | Use a plan key that includes the model, or review the plan details |
403 model_requires_planA pay-as-you-go key requested a plan-only model | Buy an eligible plan in Telegram. Its key is issued after payment clears. |
403 plan_inactiveThe key's plan has expired or is inactive | Use a pay-as-you-go key or buy an eligible plan |
404 model_not_foundThe model is unavailable or not in the catalog | Check the model ID in the catalog |
404 route_not_foundThe request path is not recognized | Check the endpoint list in section 4 |
429 rate_limitedThe plan key has reached its per-minute limit | Wait a minute or choose a plan with a higher limit |
413 payload_too_largeThe request exceeds the gateway's size limit | Reduce the context or attachment size |
502 upstream_unreachableThe provider did not respond or the connection was interrupted | Retry in a few seconds. Requests without valid usage are not billed. |
502 usage_unavailableThe provider did not return usage data | Retry the request; it was not billed. |
503 catalog_not_configured / price_not_configuredThe model catalog or pricing is not ready | Contact support in Telegram |
503 upstream_unconfiguredThe gateway is being configured | Try again shortly |
6 Security and privacy
API keys are stored as hashes. The server never stores the plaintext key. If you lose a key, create a new one; the old value cannot be recovered.
Conversations are not stored by the gateway. Service logs contain operational metadata such as token counts, duration, and model ID. Prompts and responses are not written to logs.
If a key is exposed, open API Key in the bot and choose the key rotation option. The new key takes effect immediately; usage history remains available. For payment issues, contact support through the bot.
7 Frequently asked questions
What does the gateway provide?
Use one account and API keys for catalog models. Purchase products and manage keys in Telegram.
Which API formats are supported?
OpenAI Chat Completions, Responses, and Anthropic Messages work with streaming or non-streaming requests.
Do catalog parameters restrict requests?
Catalog parameters are informational. Provider fields pass through; support varies by model and provider.
What does my client need?
Set the API base URL and authentication header for your chosen format. See setup examples in section 3.
Where can I find available models?
Browse the model catalog or call GET /v1/models. Use its model ID in your request.
How do I rotate a key?
Choose the key rotation option in Telegram, then update your application's environment variable with the new key.
Do wallet balances expire?
Pay-as-you-go wallet balances remain until used. Plan access follows the period shown at purchase.
How long does an invoice remain valid?
Invoices expire after 10 minutes. Unpaid invoices do not change your balance; create a new invoice after expiry.