LeuwongRRAI Gateway
API REFERENCE LEUWONGRR GATEWAY

Connect your application

Create a key, select a model, and send a compatible API request.

OpenAI · Chat & Responseshttps://api.leuwongrr.cloud/v1
Anthropic · Messageshttps://api.leuwongrr.cloud

Find model IDs in the catalog or call GET /v1/models. Use the base URL that matches your client.

On this page 7

1 Get an API key in Telegram

Manage your account and API keys in Telegram; review purchases and request activity from the dashboard.

1
Register in Telegram

Open @tokoapikey_bot and send /start. Your account is created automatically.

2
Add credit or choose a plan

Use /buy in Telegram, choose a product, then pay by QRIS or USDT. Wallet credit is added after payment is confirmed.

3
Create an API key

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.

Browse the model catalogCompare model IDs, capabilities, per-million-token pricing, and availability.→

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 · Chat Completions
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)

Shell · Claude Code
export ANTHROPIC_BASE_URL="https://api.leuwongrr.cloud"
export ANTHROPIC_AUTH_TOKEN="<API-KEY-DARI-BOT>"
claude

Codex CLI (OpenAI-compatible)

Shell · Codex CLI
export OPENAI_BASE_URL="https://api.leuwongrr.cloud/v1"
export OPENAI_API_KEY="<API-KEY-DARI-BOT>"
codex

zcode

Shell · zcode
export OPENAI_BASE_URL="https://api.leuwongrr.cloud/v1"
export OPENAI_API_KEY="<API-KEY-DARI-BOT>"
# atau lewat config provider custom — base URL sama

Cursor · 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)

Python · Anthropic SDK
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.

EndpointDescription
GET/v1/modelsList available models in the OpenAI format.
POST/v1/chat/completionsOpenAI Chat Completions: tools, structured output, streaming.
POST/v1/responsesOpenAI Responses: tools, reasoning, structured output, streaming.
POST/v1/messagesAnthropic Messages: tools, thinking, streaming.

Authentication

ClientHeader
OpenAIAuthorization: Bearer <API-KEY>
Anthropicx-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.

CodeMeaningNext step
401 invalid_api_keyThe key is invalid or has been revokedThe key is invalid or has been revokedCreate a new key in Telegram under API Key
402 insufficient_fundsThe selected wallet balance is too lowThe selected wallet balance is too lowAdd credit from the product catalog or Telegram bot
422 max_tokens_requiredThe output-limit field is not a valid numberThe output-limit field is not a valid numberCorrect 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 allowlistThe model is not included in this plan key's allowlistUse 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 modelA pay-as-you-go key requested a plan-only modelBuy an eligible plan in Telegram. Its key is issued after payment clears.
403 plan_inactiveThe key's plan has expired or is inactiveThe key's plan has expired or is inactiveUse a pay-as-you-go key or buy an eligible plan
404 model_not_foundThe model is unavailable or not in the catalogThe model is unavailable or not in the catalogCheck the model ID in the catalog
404 route_not_foundThe request path is not recognizedThe request path is not recognizedCheck the endpoint list in section 4
429 rate_limitedThe plan key has reached its per-minute limitThe plan key has reached its per-minute limitWait a minute or choose a plan with a higher limit
413 payload_too_largeThe request exceeds the gateway's size limitThe request exceeds the gateway's size limitReduce the context or attachment size
502 upstream_unreachableThe provider did not respond or the connection was interruptedThe provider did not respond or the connection was interruptedRetry in a few seconds. Requests without valid usage are not billed.
502 usage_unavailableThe provider did not return usage dataThe provider did not return usage dataRetry the request; it was not billed.
503 catalog_not_configured / price_not_configuredThe model catalog or pricing is not readyThe model catalog or pricing is not readyContact support in Telegram
503 upstream_unconfiguredThe gateway is being configuredThe gateway is being configuredTry 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.