%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home2/rezakur1/ai.rezakurnia.com/assets/
Upload File :
Create Path :
Current File : /home2/rezakur1/ai.rezakurnia.com/assets/ApiDocsPage-ChOyLLZO.js

import{r as d,j as e,L as p}from"./index-CYXd_ywS.js";import{B as f}from"./Badge-Bs3KAUoA.js";import{u as N}from"./useSEO-DSKZKCuc.js";function o({tabs:a,baseUrl:t="",title:s,className:c=""}){const[n,u]=d.useState(0),[i,h]=d.useState(!1),l=d.useRef(null);d.useEffect(()=>{u(0)},[a]),d.useEffect(()=>()=>{l.current&&window.clearTimeout(l.current)},[]);const m=a[n]??a[0],b=d.useMemo(()=>((m==null?void 0:m.code)??"").replaceAll("{{BASE_URL}}",t),[m,t]),y=async()=>{try{await navigator.clipboard.writeText(b)}catch{const r=document.createElement("textarea");r.value=b,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select();try{document.execCommand("copy")}finally{document.body.removeChild(r)}}h(!0),l.current&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>h(!1),2e3)};return m?e.jsxs("div",{className:`overflow-hidden rounded-xl border border-white/[0.08] bg-ink-950/90 ${c}`,"aria-label":s,children:[e.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto border-b border-white/[0.06] bg-white/[0.02] px-2 py-1.5",children:[a.map((r,g)=>e.jsx("button",{type:"button",onClick:()=>{u(g),h(!1)},className:`shrink-0 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors ${g===n?"bg-white/[0.07] text-white":"text-slate-500 hover:bg-white/[0.04] hover:text-slate-300"}`,children:r.label},r.label)),e.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-2 pl-2",children:[e.jsx("span",{className:"hidden text-[10px] uppercase tracking-wider text-slate-600 sm:inline",children:m.language}),e.jsx("button",{type:"button",onClick:y,className:`rounded-md border px-2 py-1 text-[11px] font-medium transition-colors ${i?"border-emerald-400/25 bg-emerald-500/10 text-emerald-300":"border-white/[0.08] bg-white/[0.03] text-slate-400 hover:bg-white/[0.06] hover:text-white"}`,children:i?"Tersalin":"Salin"})]})]}),e.jsx("pre",{className:"max-h-[520px] overflow-auto p-4 text-[12px] leading-relaxed text-slate-300",children:e.jsx("code",{className:"font-mono",children:b})})]}):null}function w({items:a}){var c;const[t,s]=d.useState(((c=a[0])==null?void 0:c.id)??"");return d.useEffect(()=>{const n=a.map(i=>document.getElementById(i.id)).filter(i=>!!i);if(n.length===0)return;const u=new IntersectionObserver(i=>{const h=i.filter(l=>l.isIntersecting).sort((l,m)=>l.boundingClientRect.top-m.boundingClientRect.top);h[0]&&s(h[0].target.id)},{rootMargin:"-96px 0px -65% 0px",threshold:[0,1]});return n.forEach(i=>u.observe(i)),()=>u.disconnect()},[a]),e.jsx("nav",{className:"hidden xl:block","aria-label":"Daftar isi dokumentasi",children:e.jsxs("div",{className:"sticky top-24",children:[e.jsx("p",{className:"mb-2 text-[10px] font-semibold uppercase tracking-widest text-slate-600",children:"On this page"}),e.jsx("ul",{className:"space-y-0.5 border-l border-white/[0.06]",children:a.map(n=>{const u=n.id===t;return e.jsx("li",{children:e.jsx("a",{href:`#${n.id}`,className:`-ml-px block border-l py-1.5 pl-3 text-xs transition-colors ${u?"border-brand-400 text-white":"border-transparent text-slate-500 hover:border-white/20 hover:text-slate-300"}`,children:n.title})},n.id)})})]})})}const v={GET:"border-emerald-400/25 bg-emerald-500/10 text-emerald-300",POST:"border-blue-400/25 bg-blue-500/10 text-blue-300",PATCH:"border-amber-400/25 bg-amber-500/10 text-amber-300",DELETE:"border-red-400/25 bg-red-500/10 text-red-300"};function k({method:a,path:t,auth:s="API Key"}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[e.jsx("span",{className:`inline-flex items-center rounded-md border px-2 py-1 text-[11px] font-bold tracking-wide ${v[a]}`,children:a}),e.jsx("code",{className:"break-all font-mono text-sm font-medium text-white",children:t}),e.jsx("span",{className:"chip ml-auto",children:s})]})}const A="https://api.rezakurnia.com",j=[{id:"quickstart",title:"Mulai Cepat"},{id:"authentication",title:"Autentikasi"},{id:"chat-completions",title:"Chat Completions"},{id:"streaming",title:"Streaming"},{id:"models",title:"Daftar Model"},{id:"errors",title:"Error & Kuota"},{id:"integration",title:"Tips Integrasi"}],E=[{label:"cURL",language:"bash",code:`curl -s {{BASE_URL}}/v1/models \\
  -H "Authorization: Bearer $KURNIADEV_API_KEY"`},{label:"JavaScript",language:"javascript",code:`const res = await fetch("{{BASE_URL}}/v1/models", {
  headers: {
    Authorization: \`Bearer \${process.env.KURNIADEV_API_KEY}\`,
  },
});

const data = await res.json();
console.log(data.data);`},{label:"Python",language:"python",code:`import os
import requests

res = requests.get(
    "{{BASE_URL}}/v1/models",
    headers={"Authorization": f"Bearer {os.environ['KURNIADEV_API_KEY']}"},
    timeout=30,
)

print(res.json()["data"])`}],S=[{name:"model",type:"string",required:!0,description:"ID model yang ingin dipakai. Ambil daftar yang tersedia dari GET /v1/models."},{name:"messages",type:"array",required:!0,description:"Riwayat percakapan. Setiap item berisi role (system, user, assistant, atau tool) dan content."},{name:"stream",type:"boolean",description:"Jika true, respons dikirim bertahap sebagai Server-Sent Events (SSE). Default false."},{name:"temperature",type:"number",description:"Tingkat kreativitas jawaban (umumnya 0–2). Nilai rendah lebih deterministik."},{name:"max_tokens",type:"integer",description:"Batas maksimum token yang dihasilkan pada respons ini (tergantung dukungan model)."},{name:"top_p",type:"number",description:"Nucleus sampling. Alternatif temperature; gunakan salah satu, jangan keduanya."},{name:"stop",type:"string | string[]",description:"Satu atau beberapa urutan teks yang menghentikan generasi."},{name:"presence_penalty",type:"number",description:"Penalti untuk topik yang sudah muncul (umumnya -2 sampai 2)."},{name:"frequency_penalty",type:"number",description:"Penalti untuk token yang sering muncul (umumnya -2 sampai 2)."},{name:"tools",type:"array",description:"Definisi function/tool untuk function calling, jika model yang dipilih mendukung."},{name:"tool_choice",type:"string | object",description:"Kontrol pemakaian tool: auto, none, required, atau objek tool tertentu."},{name:"user",type:"string",description:"Identifier unik pengguna akhir untuk membantu pelacakan penyalahgunaan."}],_=`{
  "model": "MODEL_NAME",
  "messages": [
    {
      "role": "system",
      "content": "Kamu adalah asisten yang ringkas dan membantu."
    },
    {
      "role": "user",
      "content": "Jelaskan apa itu API gateway dalam 2 kalimat."
    }
  ],
  "temperature": 0.7,
  "max_tokens": 512
}`,I=[{label:"cURL",language:"bash",code:`curl -s {{BASE_URL}}/v1/chat/completions \\
  -H "Authorization: Bearer $KURNIADEV_API_KEY" \\
  -H "Content-Type: application/json" \\
  -d '{
    "model": "MODEL_NAME",
    "messages": [
      {"role": "user", "content": "Halo! Perkenalkan dirimu."}
    ]
  }'`},{label:"JavaScript",language:"javascript",code:`const res = await fetch("{{BASE_URL}}/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: \`Bearer \${process.env.KURNIADEV_API_KEY}\`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "MODEL_NAME",
    messages: [
      { role: "user", content: "Halo! Perkenalkan dirimu." },
    ],
  }),
});

if (!res.ok) {
  const err = await res.json();
  throw new Error(err.error?.message ?? "Request gagal");
}

const data = await res.json();
console.log(data.choices[0].message.content);`},{label:"Python",language:"python",code:`import os
import requests

res = requests.post(
    "{{BASE_URL}}/v1/chat/completions",
    headers={
        "Authorization": f"Bearer {os.environ['KURNIADEV_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "model": "MODEL_NAME",
        "messages": [
            {"role": "user", "content": "Halo! Perkenalkan dirimu."}
        ],
    },
    timeout=60,
)

res.raise_for_status()
print(res.json()["choices"][0]["message"]["content"])`}],P=`{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1730000000,
  "model": "MODEL_NAME",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Halo! Saya asisten AI yang siap membantu Anda."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 18,
    "completion_tokens": 14,
    "total_tokens": 32
  }
}`,R=[{label:"cURL",language:"bash",code:`curl -N {{BASE_URL}}/v1/chat/completions \\
  -H "Authorization: Bearer $KURNIADEV_API_KEY" \\
  -H "Content-Type: application/json" \\
  -d '{
    "model": "MODEL_NAME",
    "stream": true,
    "messages": [
      {"role": "user", "content": "Hitung 1 sampai 5."}
    ]
  }'`},{label:"JavaScript",language:"javascript",code:`const res = await fetch("{{BASE_URL}}/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: \`Bearer \${process.env.KURNIADEV_API_KEY}\`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "MODEL_NAME",
    stream: true,
    messages: [{ role: "user", content: "Hitung 1 sampai 5." }],
  }),
});

const reader = res.body.getReader();
const decoder = new TextDecoder();

while (true) {
  const { value, done } = await reader.read();
  if (done) break;

  const chunk = decoder.decode(value, { stream: true });
  for (const line of chunk.split("\\n")) {
    if (!line.startsWith("data: ")) continue;

    const payload = line.slice(6).trim();
    if (payload === "[DONE]") continue;

    try {
      const json = JSON.parse(payload);
      process.stdout.write(json.choices?.[0]?.delta?.content ?? "");
    } catch {
      // abaikan potongan yang belum lengkap
    }
  }
}`},{label:"Python",language:"python",code:`import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["KURNIADEV_API_KEY"],
    base_url="{{BASE_URL}}/v1",
)

stream = client.chat.completions.create(
    model="MODEL_NAME",
    messages=[{"role": "user", "content": "Hitung 1 sampai 5."}],
    stream=True,
)

for chunk in stream:
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)`}],C=`data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Halo"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}

data: [DONE]`,T=[{label:"cURL",language:"bash",code:`curl -s {{BASE_URL}}/v1/models \\
  -H "Authorization: Bearer $KURNIADEV_API_KEY"`},{label:"JavaScript",language:"javascript",code:`const res = await fetch("{{BASE_URL}}/v1/models", {
  headers: {
    Authorization: \`Bearer \${process.env.KURNIADEV_API_KEY}\`,
  },
});

const { data } = await res.json();
console.log(data.map((model) => model.id));`}],B=`{
  "object": "list",
  "data": [
    {
      "id": "MODEL_NAME",
      "object": "model",
      "created": 0
    }
  ]
}`,K=[{status:"400",title:"Bad Request",description:"Body JSON tidak valid, parameter wajib kosong, atau nama model tidak dikirim."},{status:"401",title:"Unauthorized",description:"Header Authorization hilang, format key salah, key nonaktif, atau key tidak terdaftar."},{status:"402",title:"Payment Required",description:"Saldo wallet habis atau kuota paket aktif sudah terpakai. Lakukan top up atau beli paket baru."},{status:"403",title:"Forbidden",description:"Model sedang disembunyikan admin atau akun tidak memiliki akses ke model tersebut."},{status:"404",title:"Not Found",description:"Path endpoint salah. Pastikan memakai /v1/chat/completions, bukan /chat/completions."},{status:"429",title:"Too Many Requests",description:"Batas laju request dari penyedia model tercapai. Tunggu sebentar lalu coba lagi."},{status:"500",title:"Internal Server Error",description:"Terjadi kesalahan tak terduga di sisi penyedia model."},{status:"502",title:"Bad Gateway",description:"Penyedia model sedang tidak dapat dihubungi. Coba lagi beberapa saat lagi."},{status:"503",title:"Service Unavailable",description:"Layanan autentikasi sedang bermasalah, atau model sedang dalam maintenance."}],O=[{label:"JavaScript",language:"javascript",code:`import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.KURNIADEV_API_KEY,
  baseURL: "{{BASE_URL}}/v1",
});

const res = await client.chat.completions.create({
  model: "MODEL_NAME",
  messages: [{ role: "user", content: "Halo!" }],
});

console.log(res.choices[0].message.content);`},{label:"Python",language:"python",code:`import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["KURNIADEV_API_KEY"],
    base_url="{{BASE_URL}}/v1",
)

res = client.chat.completions.create(
    model="MODEL_NAME",
    messages=[{"role": "user", "content": "Halo!"}],
)

print(res.choices[0].message.content)`}];function x({id:a,title:t,intro:s,children:c}){return e.jsxs("section",{id:a,className:"scroll-mt-24",children:[e.jsx("h3",{className:"text-base font-semibold text-white sm:text-lg",children:t}),s&&e.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-relaxed text-slate-500",children:s}),e.jsx("div",{className:"mt-4 space-y-4",children:c})]})}function D({text:a}){const[t,s]=d.useState(!1),c=async()=>{try{await navigator.clipboard.writeText(a)}catch{}s(!0),window.setTimeout(()=>s(!1),2e3)};return e.jsx("button",{type:"button",onClick:c,className:`shrink-0 rounded-md border px-2.5 py-1 text-[11px] font-medium transition-colors ${t?"border-emerald-400/25 bg-emerald-500/10 text-emerald-300":"border-white/[0.08] bg-white/[0.03] text-slate-400 hover:bg-white/[0.06] hover:text-white"}`,children:t?"Tersalin":"Salin"})}function U(a){return a.startsWith("2")?"border-emerald-400/20 bg-emerald-500/10 text-emerald-300":a.startsWith("4")?"border-amber-400/20 bg-amber-500/10 text-amber-300":"border-red-400/20 bg-red-500/10 text-red-300"}const L=[{num:"1",title:"Buat API key",desc:"Buat key baru di halaman API Keys. Key lengkap hanya ditampilkan satu kali.",link:"/keys",linkLabel:"Buka API Keys"},{num:"2",title:"Simpan sebagai environment variable",desc:"Simpan key di server Anda, jangan di kode frontend atau repository publik.",code:"KURNIADEV_API_KEY=kd_live_..."},{num:"3",title:"Kirim request pertama",desc:"Panggil endpoint chat completions dengan model yang tersedia di katalog.",code:"POST /v1/chat/completions"}];function J(){N({title:"API Documentation",description:"Panduan integrasi Chat Completions KURNIADEV AI: autentikasi, parameter, streaming, dan penanganan error.",canonicalPath:"/docs"});const a=A;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 border-b border-white/[0.06] pb-6 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(f,{tone:"info",children:"v1"}),e.jsx("span",{className:"text-[11px] font-medium text-slate-500",children:"OpenAI-compatible API"})]}),e.jsx("h2",{className:"text-xl font-bold tracking-tight text-white sm:text-2xl",children:"API Documentation"}),e.jsx("p",{className:"mt-1 max-w-2xl text-sm leading-relaxed text-slate-500",children:"Panduan lengkap memakai Chat Completions di KURNIADEV AI Gateway — mulai dari membuat API key sampai streaming respons."})]}),e.jsxs(p,{to:"/keys",className:"inline-flex shrink-0 items-center gap-2 rounded-xl border border-brand-400/25 bg-brand-500/10 px-3.5 py-2 text-xs font-semibold text-brand-300 transition hover:bg-brand-500/15 hover:text-brand-200",children:["Buat API Key",e.jsx("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 4.5L21 12l-7.5 7.5M21 12H3"})})]})]}),e.jsxs("div",{className:"panel p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-slate-500",children:"Base URL"}),e.jsx("p",{className:"mt-1 text-[11px] text-slate-500",children:"Semua contoh di halaman ini memakai base URL produksi."})]}),e.jsx("span",{className:"chip",children:"Produksi"})]}),e.jsxs("div",{className:"mt-3 flex items-center gap-2 rounded-xl border border-white/[0.06] bg-ink-950/80 px-3 py-2.5",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-600",children:"API"}),e.jsxs("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-brand-300",children:[a,"/v1"]}),e.jsx(D,{text:`${a}/v1`})]})]}),e.jsx("div",{className:"xl:hidden",children:e.jsx("div",{className:"flex gap-1.5 overflow-x-auto pb-1",children:j.map(t=>e.jsx("a",{href:`#${t.id}`,className:"shrink-0 rounded-full border border-white/[0.08] bg-white/[0.03] px-3 py-1.5 text-[11px] font-medium text-slate-400 transition hover:bg-white/[0.06] hover:text-white",children:t.title},t.id))})}),e.jsxs("div",{className:"grid gap-10 xl:grid-cols-[minmax(0,1fr)_220px]",children:[e.jsxs("div",{className:"min-w-0 space-y-10",children:[e.jsx(x,{id:"quickstart",title:"Mulai Cepat",intro:"Tiga langkah untuk mengirim request pertama ke gateway.",children:e.jsx("div",{className:"grid gap-3 sm:grid-cols-3",children:L.map(t=>e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] p-4",children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-full border border-brand-400/25 bg-brand-500/10 text-[11px] font-bold text-brand-300",children:t.num}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-white",children:t.title}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-slate-500",children:t.desc}),t.link&&e.jsxs(p,{to:t.link,className:"mt-3 inline-flex text-[11px] font-semibold text-brand-300 hover:text-brand-200",children:[t.linkLabel," →"]}),t.code&&e.jsx("code",{className:"mt-3 block overflow-x-auto rounded-lg border border-white/[0.06] bg-ink-950/80 px-2.5 py-1.5 font-mono text-[10px] text-slate-400",children:t.code})]},t.num))})}),e.jsxs(x,{id:"authentication",title:"Autentikasi",intro:"Semua request ke endpoint /v1/* wajib menyertakan API key pada header Authorization.",children:[e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] p-4",children:[e.jsx("p",{className:"text-xs leading-relaxed text-slate-400",children:"Format header:"}),e.jsx("code",{className:"mt-2 block overflow-x-auto rounded-lg border border-white/[0.06] bg-ink-950/80 px-3 py-2 font-mono text-xs text-slate-200",children:"Authorization: Bearer kd_live_..."}),e.jsxs("ul",{className:"mt-3 space-y-1.5 text-xs leading-relaxed text-slate-500",children:[e.jsxs("li",{children:["• API key dibuat dari halaman"," ",e.jsx(p,{to:"/keys",className:"font-medium text-brand-300 hover:text-brand-200",children:"API Keys"})," ","dan hanya ditampilkan satu kali."]}),e.jsxs("li",{children:["• Key yang sudah di-revoke atau nonaktif akan ditolak dengan status ",e.jsx("span",{className:"text-amber-300",children:"401"}),"."]}),e.jsx("li",{children:"• Jangan menaruh key di kode frontend, repository publik, atau aplikasi mobile yang bisa dibongkar."})]})]}),e.jsx(o,{tabs:E,baseUrl:a,title:"Contoh autentikasi"})]}),e.jsxs(x,{id:"chat-completions",title:"Chat Completions",intro:"Endpoint utama untuk menghasilkan jawaban dari model chat. Format request dan respons kompatibel dengan OpenAI Chat Completions.",children:[e.jsxs("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] p-4",children:[e.jsx(k,{method:"POST",path:"/v1/chat/completions"}),e.jsxs("p",{className:"mt-3 text-xs leading-relaxed text-slate-500",children:["Kirim riwayat percakapan pada field ",e.jsx("code",{className:"text-slate-300",children:"messages"}),". Sertakan pesan ",e.jsx("code",{className:"text-slate-300",children:"system"})," di awal untuk mengatur gaya jawaban, lalu pesan ",e.jsx("code",{className:"text-slate-300",children:"user"})," ","untuk pertanyaan."]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-xs font-semibold uppercase tracking-wider text-slate-500",children:"Parameter"}),e.jsx("div",{className:"overflow-x-auto rounded-xl border border-white/[0.06]",children:e.jsxs("table",{className:"w-full min-w-[640px] text-left text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/[0.06] bg-white/[0.02] text-[10px] uppercase tracking-wider text-slate-500",children:[e.jsx("th",{className:"px-4 py-2.5 font-semibold",children:"Field"}),e.jsx("th",{className:"px-4 py-2.5 font-semibold",children:"Tipe"}),e.jsx("th",{className:"px-4 py-2.5 font-semibold",children:"Keterangan"})]})}),e.jsx("tbody",{className:"divide-y divide-white/[0.04]",children:S.map(t=>e.jsxs("tr",{children:[e.jsxs("td",{className:"whitespace-nowrap px-4 py-3 align-top",children:[e.jsx("code",{className:"font-mono text-xs text-white",children:t.name}),t.required&&e.jsx("span",{className:"ml-2 text-[9px] font-bold uppercase tracking-wide text-red-300",children:"wajib"})]}),e.jsx("td",{className:"whitespace-nowrap px-4 py-3 align-top font-mono text-[11px] text-slate-500",children:t.type}),e.jsx("td",{className:"px-4 py-3 align-top text-xs leading-relaxed text-slate-400",children:t.description})]},t.name))})]})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-xs font-semibold uppercase tracking-wider text-slate-500",children:"Contoh body"}),e.jsx(o,{tabs:[{label:"JSON",language:"json",code:_}],baseUrl:a,title:"Contoh body chat completions"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-xs font-semibold uppercase tracking-wider text-slate-500",children:"Contoh request"}),e.jsx(o,{tabs:I,baseUrl:a,title:"Contoh request chat completions"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-xs font-semibold uppercase tracking-wider text-slate-500",children:"Contoh respons"}),e.jsx(o,{tabs:[{label:"JSON",language:"json",code:P}],baseUrl:a,title:"Contoh respons chat completions"}),e.jsxs("p",{className:"mt-2 text-[11px] leading-relaxed text-slate-500",children:["Jawaban ada di ",e.jsx("code",{className:"text-slate-300",children:"choices[0].message.content"}),". Field ",e.jsx("code",{className:"text-slate-300",children:"usage"})," menampilkan jumlah token yang dipakai untuk perhitungan biaya."]})]})]}),e.jsxs(x,{id:"streaming",title:"Streaming",intro:"Aktifkan stream: true agar jawaban muncul bertahap. Respons dikirim sebagai Server-Sent Events (SSE) dengan awalan data: dan diakhiri data: [DONE].",children:[e.jsx(o,{tabs:R,baseUrl:a,title:"Contoh streaming"}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-xs font-semibold uppercase tracking-wider text-slate-500",children:"Bentuk respons SSE"}),e.jsx(o,{tabs:[{label:"SSE",language:"text",code:C}],baseUrl:a,title:"Contoh respons streaming"})]})]}),e.jsxs(x,{id:"models",title:"Daftar Model",intro:"Gunakan endpoint ini untuk melihat model yang tersedia. Nilai id dari respons dipakai sebagai field model pada chat completions.",children:[e.jsx("div",{className:"rounded-xl border border-white/[0.06] bg-white/[0.02] p-4",children:e.jsx(k,{method:"GET",path:"/v1/models"})}),e.jsx(o,{tabs:T,baseUrl:a,title:"Contoh daftar model"}),e.jsx(o,{tabs:[{label:"JSON",language:"json",code:B}],baseUrl:a,title:"Contoh respons daftar model"}),e.jsxs("p",{className:"text-[11px] leading-relaxed text-slate-500",children:["Katalog, harga per 1 juta token, dan tes model bisa dilihat di halaman"," ",e.jsx(p,{to:"/models",className:"font-medium text-brand-300 hover:text-brand-200",children:"Model"}),". Nama model harus persis sama dengan yang ada di katalog."]})]}),e.jsxs(x,{id:"errors",title:"Error & Kuota",intro:"Semua error memakai bentuk yang sama: { error: { message, type } }. Berikut status yang paling sering muncul.",children:[e.jsx("div",{className:"overflow-x-auto rounded-xl border border-white/[0.06]",children:e.jsxs("table",{className:"w-full min-w-[560px] text-left text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/[0.06] bg-white/[0.02] text-[10px] uppercase tracking-wider text-slate-500",children:[e.jsx("th",{className:"px-4 py-2.5 font-semibold",children:"Status"}),e.jsx("th",{className:"px-4 py-2.5 font-semibold",children:"Arti"}),e.jsx("th",{className:"px-4 py-2.5 font-semibold",children:"Keterangan"})]})}),e.jsx("tbody",{className:"divide-y divide-white/[0.04]",children:K.map(t=>e.jsxs("tr",{children:[e.jsx("td",{className:"whitespace-nowrap px-4 py-3 align-top",children:e.jsx("span",{className:`inline-flex rounded-md border px-2 py-0.5 font-mono text-[11px] font-bold ${U(t.status)}`,children:t.status})}),e.jsx("td",{className:"whitespace-nowrap px-4 py-3 align-top text-xs font-medium text-slate-300",children:t.title}),e.jsx("td",{className:"px-4 py-3 align-top text-xs leading-relaxed text-slate-400",children:t.description})]},t.status))})]})}),e.jsxs("div",{className:"rounded-xl border border-amber-400/20 bg-amber-500/[0.06] p-4",children:[e.jsx("p",{className:"text-xs font-semibold text-amber-200",children:"Tentang status 402"}),e.jsxs("p",{className:"mt-1.5 text-xs leading-relaxed text-amber-100/70",children:["Gateway memakai dua sumber kuota: saldo wallet dan paket aktif. Jika tidak ada paket aktif dan saldo wallet habis, request ditolak dengan 402. Jika paket aktif tetapi kuota request atau token sudah terpakai, request juga ditolak dengan 402. Isi saldo di halaman"," ",e.jsx(p,{to:"/topup",className:"font-semibold text-amber-200 underline-offset-2 hover:underline",children:"Top Up"})," ","atau beli paket di halaman"," ",e.jsx(p,{to:"/packages",className:"font-semibold text-amber-200 underline-offset-2 hover:underline",children:"Paket"}),"."]})]}),e.jsx(o,{tabs:[{label:"JSON",language:"json",code:`{
  "error": {
    "message": "Kuota layanan sedang tidak tersedia. Silakan coba lagi nanti atau hubungi admin.",
    "type": "insufficient_quota"
  }
}`}],baseUrl:a,title:"Contoh respons 402"})]}),e.jsxs(x,{id:"integration",title:"Tips Integrasi",intro:"Gateway ini kompatibel dengan OpenAI SDK. Cukup ganti base URL dan API key.",children:[e.jsx(o,{tabs:O,baseUrl:a,title:"Contoh OpenAI SDK"}),e.jsxs("ul",{className:"space-y-2 text-xs leading-relaxed text-slate-500",children:[e.jsx("li",{children:"• Simpan API key di environment variable server, bukan di kode yang dikirim ke browser."}),e.jsx("li",{children:"• Gunakan timeout yang wajar (misalnya 30–120 detik) dan retry dengan exponential backoff untuk status 429, 500, 502, dan 503."}),e.jsx("li",{children:"• Untuk jawaban panjang, aktifkan streaming agar pengguna melihat respons lebih cepat."}),e.jsxs("li",{children:["• Pantau pemakaian dan biaya di halaman"," ",e.jsx(p,{to:"/usage",className:"font-medium text-brand-300 hover:text-brand-200",children:"Usage"})," ","dan"," ",e.jsx(p,{to:"/billing",className:"font-medium text-brand-300 hover:text-brand-200",children:"Billing"}),"."]})]})]})]}),e.jsx(w,{items:j})]})]})}export{J as default};

Zerion Mini Shell 1.0