Dokumentasi

Chat Completions, streaming, tools, dan vision.

MethodEndpointFungsi
POST/v1/chat/completionsChat, streaming, tools, vision
POST/v1/images/generationsGenerate gambar
GET/v1/modelsDaftar model dan tarif
GET/v1/accountInfo key dan saldo
python
from openai import OpenAI

client = OpenAI(base_url="https://api.tokenbyte.biz.id/v1", api_key="sk-tkn-KEY_KAMU")

stream = client.chat.completions.create(
    model="smart-auto",
    messages=[{"role": "user", "content": "Tulis pantun tentang kopi."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")
node
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.tokenbyte.biz.id/v1", apiKey: "sk-tkn-KEY_KAMU" });

const res = await client.chat.completions.create({
  model: "smart-auto",
  messages: [{ role: "user", content: "Tulis pantun tentang kopi." }],
});
console.log(res.choices[0].message.content, res.usage);

Vision

Kirim gambar sebagai image_url (URL atau data URI base64) ke model yang bertanda Vision.

json
{
  "model": "smart-auto",
  "messages": [{
    "role": "user",
    "content": [
      {"type": "text", "text": "Apa isi gambar ini?"},
      {"type": "image_url", "image_url": {"url": "https://contoh.com/foto.jpg"}}
    ]
  }]
}

Pemakaian saat streaming

Tambahkan stream_options: {"include_usage": true} supaya chunk terakhir memuat usage beserta billed_tokens.

Endpoint /v1/responses dan /v1/embeddings belum tersedia.