> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neosantara.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# LiteLLM

> Orkestrasi model AI, proxy load balancing, dan fallback routing dengan LiteLLM.

Neosantara didukung secara resmi di dalam ekosistem [LiteLLM](https://www.litellm.ai/?utm_source=neosantara-docs\&utm_medium=referral). Anda dapat memanggil model menggunakan prefix `neosantara/<model>` untuk routing, failover multi-model otomatis, dan pelacakan biaya terpusat.

## Instalasi

```bash theme={"theme":{"light":"catppuccin-latte","dark":"ayu-dark"}}
pip install -U litellm
```

## Autentikasi

Setel API key Neosantara di environment:

```bash theme={"theme":{"light":"catppuccin-latte","dark":"ayu-dark"}}
export NEOSANTARA_API_KEY="nsk_..."
```

## Contoh Penggunaan Native

```python Python icon="python" theme={"theme":{"light":"catppuccin-latte","dark":"ayu-dark"}}
import litellm
import os

response = litellm.completion(
    model="neosantara/gemini-3.8-flash",
    messages=[
        {"role": "user", "content": "Jelaskan cara kerja proxy AI dalam satu kalimat."}
    ]
)

print(response.choices[0].message.content)
```

```python Python (Streaming) icon="python" theme={"theme":{"light":"catppuccin-latte","dark":"ayu-dark"}}
import litellm

response = litellm.completion(
    model="neosantara/deepseek-v4.1-flash",
    messages=[{"role": "user", "content": "Tuliskan 3 tips optimasi database."}],
    stream=True
)

for chunk in response:
    content = chunk.choices[0].delta.content or ""
    print(content, end="", flush=True)
print()
```

## Eksekusi Responses API

Neosantara mendukung endpoint OpenResponses (`/v1/responses`) untuk eksekusi persisten dan pelacakan state. Anda dapat memanggil fungsi `litellm.responses`:

```python theme={"theme":{"light":"catppuccin-latte","dark":"ayu-dark"}}
import litellm
import os

response = litellm.responses(
    model="neosantara/gemini-3.8-flash",
    input="Tuliskan ringkasan keunggulan regional AI gateway dalam 2 poin."
)

print(response.output[0].content[0].text)
print(f"Response ID: {response.id}")
```

## Konfigurasi Proxy LiteLLM (`config.yaml`)

Jika Anda menjalankan LiteLLM Proxy Server untuk organisasi:

```yaml config.yaml theme={"theme":{"light":"catppuccin-latte","dark":"ayu-dark"}}
model_list:
  - model_name: my-fast-model
    litellm_params:
      model: neosantara/gemini-3.8-flash
      api_key: os.environ/NEOSANTARA_API_KEY

  - model_name: my-reasoning-model
    litellm_params:
      model: neosantara/deepseek-v4.1-flash
      api_key: os.environ/NEOSANTARA_API_KEY
```

## Keunggulan Integrasi LiteLLM

| Kapabilitas | Integrasi Standar | Provider Resmi Neosantara |
| :- | :- | :- |
| **Sintaks Model** | `openai/<model>` | `neosantara/<model>` |
| **Routing & Fallback** | Konfigurasi manual per endpoint | Failover multi-model otomatis |
| **Pelacakan Biaya & Saldo** | Estimasi token statis | Selaras dengan rate Rupiah Neosantara |
| **Dukungan Proxy & Gateway** | Perlu mapping adapter tambahan | Terdaftar langsung di server proxy LiteLLM |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.