> ## 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":"ayu-dark","dark":"catppuccin-latte"}}
pip install -U litellm
```

## Autentikasi

Setel API key Neosantara di environment:

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

## Contoh Penggunaan Native

<CodeGroup>
  ```python Python icon="python" theme={"theme":{"light":"ayu-dark","dark":"catppuccin-latte"}}
  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":"ayu-dark","dark":"catppuccin-latte"}}
  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()
  ```
</CodeGroup>

## 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":"ayu-dark","dark":"catppuccin-latte"}}
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":"ayu-dark","dark":"catppuccin-latte"}}
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 |


## Related topics

- [Ringkasan Integrasi](/id/integrations/overview.md)
- [Any-LLM](/id/integrations/any-llm.md)
- [Katalog Model](/id/gateway/models.md)
- [Chat Completions](/id/gateway/chat-completions.md)
