Docs

TokenFlow API documentation

TokenFlow exposes one API that is compatible with both the OpenAI and the Anthropic formats. Use it from the SDKs, from coding tools such as OpenCode, Claude Code and Hermes, or straight over HTTP.

  • Base URLhttps://api.tokenflow.id/v1
  • AuthenticationAuthorization: Bearer sk-tf-…
  • FormatsOpenAI & Anthropic compatible
  1. Getting started

    • Choose a package on the home page, verify your Telegram, then pay with QRIS. Your account activates automatically.
    • Your API key (sk-tf-…) is shown once after payment. Save it somewhere safe.
    • Sign in to the Portal to see your balance and usage, reopen your API key with your PIN, or create a new key.
    • The quickest route is Portal → Guide: pick a tool and your OS, copy one command and run it in a terminal.
  2. Authentication

    Send your API key on every request in the Authorization header:

    Authorization: Bearer sk-tf-YOUR_API_KEY

    The Anthropic-compatible endpoint /v1/messages also accepts the x-api-key header. Never put your API key in front-end code or a public repository; if it leaks, create a new key in the Portal.

  3. Model list

    Get the model IDs available to your account. Use the id value as model in requests.

    curl https://api.tokenflow.id/v1/models \
        -H "Authorization: Bearer $TOKENFLOW_API_KEY"

    The list follows provider availability and can change. The catalog on the home page also shows each model's grade and multiplier.

  4. Chat Completions (OpenAI-compatible)

    POST /v1/chat/completions takes the OpenAI format. model and messages are required.

    curl
    curl https://api.tokenflow.id/v1/chat/completions \
        -H "Authorization: Bearer $TOKENFLOW_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "model": "glm-5.3",
          "messages": [{"role": "user", "content": "Hello!"}]
        }'
    Python (openai)
    from openai import OpenAI
    
      client = OpenAI(base_url="https://api.tokenflow.id/v1", api_key="sk-tf-YOUR_API_KEY")
      reply = client.chat.completions.create(
          model="glm-5.3",
          messages=[{"role": "user", "content": "Hello!"}],
      )
      print(reply.choices[0].message.content)
    Node.js (openai)
    import OpenAI from "openai";
    
      const client = new OpenAI({ baseURL: "https://api.tokenflow.id/v1", apiKey: process.env.TOKENFLOW_API_KEY });
      const reply = await client.chat.completions.create({
        model: "glm-5.3",
        messages: [{ role: "user", content: "Hello!" }],
      });
      console.log(reply.choices[0].message.content);
  5. Messages (Anthropic-compatible)

    POST /v1/messages takes the Anthropic format. model, messages and max_tokens are required.

    curl
    curl https://api.tokenflow.id/v1/messages \
        -H "x-api-key: $TOKENFLOW_API_KEY" \
        -H "anthropic-version: 2023-06-01" \
        -H "Content-Type: application/json" \
        -d '{
          "model": "glm-5.3",
          "max_tokens": 1024,
          "messages": [{"role": "user", "content": "Hello!"}]
        }'
    Python (anthropic)
    import anthropic
    
      client = anthropic.Anthropic(base_url="https://api.tokenflow.id", api_key="sk-tf-YOUR_API_KEY")
      reply = client.messages.create(
          model="glm-5.3",
          max_tokens=1024,
          messages=[{"role": "user", "content": "Hello!"}],
      )
      print(reply.content[0].text)

    The Anthropic SDK and Claude Code add /v1/messages themselves, so their base URL is https://api.tokenflow.id without /v1.

  6. Streaming

    Add "stream": true to the body of either endpoint to receive the response bit by bit as Server-Sent Events, in the same format as OpenAI or Anthropic. Token usage is still counted once the stream finishes.

    curl -N https://api.tokenflow.id/v1/chat/completions \
        -H "Authorization: Bearer $TOKENFLOW_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{"model": "glm-5.3", "stream": true, "messages": [{"role": "user", "content": "Hello!"}]}'
  7. Coding tools

    The Portal Guide builds a ready-made command for OpenCode, Claude Code and Hermes on Linux, macOS and Windows, and gives 9Router setup steps. To configure a tool by hand:

    ToolFormatBase URL
    OpenCode, Hermes, 9Router, other OpenAI-compatible clientsOpenAIhttps://api.tokenflow.id/v1
    Claude Code, Anthropic SDKAnthropichttps://api.tokenflow.id
    Claude Code, by hand (Linux/macOS)
    export ANTHROPIC_BASE_URL="https://api.tokenflow.id"
      export ANTHROPIC_AUTH_TOKEN="sk-tf-YOUR_API_KEY"
      export ANTHROPIC_MODEL="glm-5.3"
      export ANTHROPIC_DEFAULT_HAIKU_MODEL="glm-5.3"
      claude

    Support for non-Claude models in Claude Code depends on the gateway and is not guaranteed by Anthropic.

  8. Quota & multipliers

    • Every model has a multiplier. Tokens deducted = the request's input and output tokens × the model's multiplier.
    • A package is valid for 28 days. A top-up to the same hashtag adds quota and leftover tokens carry over to the new period.
    • See your remaining balance, request count and usage per model in the Portal. Use the Estimator to work out which package fits.
  9. Errors & limits

    Errors come back as JSON: {"error": {"code": "…", "message": "…"}}. Errors from the model provider are passed on with the same status and message, with any API key in them hidden as [redacted].

    StatusCodeMeaning
    401AUTHENTICATION_ERRORThe API key is missing, wrong or no longer active.
    413BODY_TOO_LARGEThe request body is over 2 MiB.
    422VALIDATION_ERRORmodel, messages, stream (or max_tokens for Messages) are missing or invalid.
    429RATE_LIMITEDToo many attempts with an invalid API key. Wait for the time in the Retry-After header.
    502UPSTREAM_OUTCOME_UNKNOWNThe provider did not answer clearly. The request is not retried automatically, so check before sending it again.
    503GATEWAY_UNAVAILABLEThe service is temporarily unavailable. Try again shortly.

    Still stuck? Contact us on Telegram at @Moneyvesting00.

Docs

Dokumentasi API TokenFlow

TokenFlow menyediakan satu API yang kompatibel dengan format OpenAI maupun Anthropic. Gunakan lewat SDK, coding tool seperti OpenCode, Claude Code, dan Hermes, atau langsung lewat HTTP.

  • Base URLhttps://api.tokenflow.id/v1
  • AutentikasiAuthorization: Bearer sk-tf-…
  • FormatKompatibel OpenAI & Anthropic
  1. Mulai

    • Pilih paket di halaman utama, verifikasi Telegram, lalu bayar lewat QRIS. Akun aktif otomatis.
    • API key (sk-tf-…) ditampilkan satu kali setelah pembayaran. Simpan di tempat aman.
    • Masuk ke Portal untuk melihat saldo dan pemakaian, membuka kembali API key dengan PIN, atau membuat key baru.
    • Cara tercepat: Portal → Panduan. Pilih tool dan OS, salin satu command, lalu jalankan di terminal.
  2. Autentikasi

    Kirim API key di setiap request melalui header Authorization:

    Authorization: Bearer sk-tf-API_KEY_KAMU

    Endpoint kompatibel Anthropic /v1/messages juga menerima header x-api-key. Jangan menaruh API key di kode front-end atau repository publik; jika bocor, buat key baru di Portal.

  3. Daftar model

    Ambil ID model yang tersedia untuk akunmu. Pakai nilai id sebagai model pada request.

    curl https://api.tokenflow.id/v1/models \
        -H "Authorization: Bearer $TOKENFLOW_API_KEY"

    Daftar mengikuti ketersediaan provider dan dapat berubah. Katalog di halaman utama juga menampilkan grade dan multiplier tiap model.

  4. Chat Completions (kompatibel OpenAI)

    POST /v1/chat/completions menerima format OpenAI. model dan messages wajib diisi.

    curl
    curl https://api.tokenflow.id/v1/chat/completions \
        -H "Authorization: Bearer $TOKENFLOW_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "model": "glm-5.3",
          "messages": [{"role": "user", "content": "Halo!"}]
        }'
    Python (openai)
    from openai import OpenAI
    
      client = OpenAI(base_url="https://api.tokenflow.id/v1", api_key="sk-tf-API_KEY_KAMU")
      reply = client.chat.completions.create(
          model="glm-5.3",
          messages=[{"role": "user", "content": "Halo!"}],
      )
      print(reply.choices[0].message.content)
    Node.js (openai)
    import OpenAI from "openai";
    
      const client = new OpenAI({ baseURL: "https://api.tokenflow.id/v1", apiKey: process.env.TOKENFLOW_API_KEY });
      const reply = await client.chat.completions.create({
        model: "glm-5.3",
        messages: [{ role: "user", content: "Halo!" }],
      });
      console.log(reply.choices[0].message.content);
  5. Messages (kompatibel Anthropic)

    POST /v1/messages menerima format Anthropic. model, messages, dan max_tokens wajib diisi.

    curl
    curl https://api.tokenflow.id/v1/messages \
        -H "x-api-key: $TOKENFLOW_API_KEY" \
        -H "anthropic-version: 2023-06-01" \
        -H "Content-Type: application/json" \
        -d '{
          "model": "glm-5.3",
          "max_tokens": 1024,
          "messages": [{"role": "user", "content": "Halo!"}]
        }'
    Python (anthropic)
    import anthropic
    
      client = anthropic.Anthropic(base_url="https://api.tokenflow.id", api_key="sk-tf-API_KEY_KAMU")
      reply = client.messages.create(
          model="glm-5.3",
          max_tokens=1024,
          messages=[{"role": "user", "content": "Halo!"}],
      )
      print(reply.content[0].text)

    SDK Anthropic dan Claude Code menambahkan /v1/messages sendiri, jadi base URL-nya https://api.tokenflow.id tanpa /v1.

  6. Streaming

    Tambahkan "stream": true pada body kedua endpoint untuk menerima respons sedikit demi sedikit sebagai Server-Sent Events, dengan format yang sama seperti OpenAI atau Anthropic. Pemakaian token tetap dihitung setelah stream selesai.

    curl -N https://api.tokenflow.id/v1/chat/completions \
        -H "Authorization: Bearer $TOKENFLOW_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{"model": "glm-5.3", "stream": true, "messages": [{"role": "user", "content": "Halo!"}]}'
  7. Coding tool

    Panduan di Portal membuatkan command siap pakai untuk OpenCode, Claude Code, dan Hermes di Linux, macOS, dan Windows, serta langkah setup 9Router. Untuk mengatur tool secara manual:

    ToolFormatBase URL
    OpenCode, Hermes, 9Router, klien kompatibel OpenAI lainOpenAIhttps://api.tokenflow.id/v1
    Claude Code, SDK AnthropicAnthropichttps://api.tokenflow.id
    Claude Code manual (Linux/macOS)
    export ANTHROPIC_BASE_URL="https://api.tokenflow.id"
      export ANTHROPIC_AUTH_TOKEN="sk-tf-API_KEY_KAMU"
      export ANTHROPIC_MODEL="glm-5.3"
      export ANTHROPIC_DEFAULT_HAIKU_MODEL="glm-5.3"
      claude

    Dukungan model non-Claude di Claude Code bergantung pada gateway dan tidak dijamin Anthropic.

  8. Kuota & multiplier

    • Setiap model memiliki multiplier. Token terpotong = token input dan output request × multiplier model.
    • Masa aktif paket 28 hari. Top-up ke hashtag yang sama menambah kuota, dan sisa token terbawa ke periode baru.
    • Lihat sisa saldo, jumlah request, dan pemakaian per model di Portal. Gunakan Estimator untuk menghitung paket yang pas.
  9. Error & batasan

    Error dikembalikan sebagai JSON: {"error": {"code": "…", "message": "…"}}. Error dari penyedia model diteruskan dengan status dan pesan yang sama; API key yang tercantum di dalamnya disamarkan menjadi [redacted].

    StatusKodeArti
    401AUTHENTICATION_ERRORAPI key kosong, salah, atau sudah tidak aktif.
    413BODY_TOO_LARGEBody request lebih dari 2 MiB.
    422VALIDATION_ERRORmodel, messages, stream (atau max_tokens untuk Messages) kosong atau tidak valid.
    429RATE_LIMITEDTerlalu banyak percobaan dengan API key tidak valid. Tunggu sesuai header Retry-After.
    502UPSTREAM_OUTCOME_UNKNOWNProvider tidak memberi jawaban yang jelas. Request tidak diulang otomatis, jadi periksa dulu sebelum mengirim ulang.
    503GATEWAY_UNAVAILABLELayanan sedang tidak tersedia sementara. Coba lagi sebentar lagi.

    Masih ada kendala? Hubungi kami melalui Telegram @Moneyvesting00.