> ## 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.

# Any-LLM

> Antarmuka Python terstandarisasi untuk inferensi multi-provider, streaming, dan portabilitas model.

[Any-LLM](https://mozilla-ai.github.io/any-llm/?utm_source=neosantara-docs\&utm_medium=referral) menyediakan satu antarmuka Python terstandarisasi untuk beragam penyedia model AI. Neosantara terintegrasi secara resmi melalui ID penyedia `neosantara`, menghadirkan eksekusi streaming konsisten, penanganan parameter terpadu, dan portabilitas antar model.

## Instalasi

Pasang paket Any-LLM dengan ekstensi native Neosantara:

```bash theme={"theme":{"light":"ayu-dark","dark":"catppuccin-latte"}}
pip install "any-llm-sdk[neosantara]"
```

## Autentikasi

Ekspor API key Neosantara ke environment:

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

Penyedia native Neosantara secara otomatis mengarahkan permintaan ke `https://api.neosantara.xyz/v1`.

## Contoh Penggunaan Native

Gunakan `AnyLLM.create("neosantara")` untuk membuat klien reusable:

<CodeGroup>
  ```python Python (Reusable Client) icon="python" theme={"theme":{"light":"ayu-dark","dark":"catppuccin-latte"}}
  from any_llm import AnyLLM

  llm = AnyLLM.create("neosantara")

  response = llm.completion(
      model="gemini-3.8-flash",
      messages=[
          {"role": "user", "content": "Jelaskan keunggulan AI Gateway Indonesia dalam satu kalimat."}
      ]
  )

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

  ```python Python (Fungsi Tunggal) icon="python" theme={"theme":{"light":"ayu-dark","dark":"catppuccin-latte"}}
  from any_llm import completion

  response = completion(
      model="neosantara/gemini-3.8-flash",
      messages=[
          {"role": "user", "content": "Apa itu sistem terdistribusi?"}
      ]
  )

  print(response.choices[0].message.content)
  ```
</CodeGroup>

## Streaming Respons

Any-LLM mendukung streaming token inkremental secara langsung:

```python theme={"theme":{"light":"ayu-dark","dark":"catppuccin-latte"}}
from any_llm import AnyLLM

llm = AnyLLM.create("neosantara")

stream = llm.completion(
    model="deepseek-v4.1-flash",
    messages=[{"role": "user", "content": "Tuliskan panduan singkat."}],
    stream=True
)

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

## Keunggulan Integrasi Any-LLM

| Fitur                          | Pendekatan Wrapper Manual                          | Provider Resmi Neosantara                   |
| :----------------------------- | :------------------------------------------------- | :------------------------------------------ |
| **Inisialisasi Klien**         | Inisialisasi adapter OpenAI kustom per pemanggilan | `AnyLLM.create("neosantara")` instan        |
| **Portabilitas Kode**          | Terikat ke SDK vendor spesifik                     | Satu antarmuka universal untuk rotasi model |
| **Streaming & Response Shape** | Normalisasi chunks berbeda-beda per upstream       | Output stream standar yang seragam          |
| **Manajemen Environment**      | Pengaturan endpoint di banyak file konfigurasi     | Sentralisasi via `NEOSANTARA_API_KEY`       |


## Related topics

- [Ringkasan Integrasi](/id/integrations/overview.md)
- [LiteLLM](/id/integrations/litellm.md)
- [Integrasi LangChain](/id/integrations/langchain.md)
- [Katalog Model](/id/gateway/models.md)
