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

# Bring Your Own LLM

> Connect any OpenAI-compatible LLM to your TruGen agents — self-hosted, fine-tuned, or third-party.

TruGen lets you replace the default LLM with any **OpenAI-compatible API**. This means you can use self-hosted models, fine-tuned models trained on your own data, or third-party providers — while keeping the rest of the avatar and agent stack intact.

## Why Use a Custom LLM?

| Benefit           | Description                                                                    |
| ----------------- | ------------------------------------------------------------------------------ |
| **Customisation** | Use domain-specific or fine-tuned models for better accuracy in your vertical  |
| **Data Privacy**  | Keep sensitive data within your own infrastructure or private cloud            |
| **Compliance**    | Meet strict regulatory requirements around data residency and auditing         |
| **Cost Control**  | Optimise expenses by choosing competitive providers or using your own hardware |

## Requirements

Your LLM API must implement the **OpenAI Chat Completions** specification:

* **Endpoint:** `POST /chat/completions`
* **Payload:** Must accept a `messages: []` array
* **Streaming:** Must support Server-Sent Events (SSE) for real-time interaction

**Optional** — required only for specific features:

* **Function Calling** — needed if your agent uses tools
* **Vision** — needed for multimodal inputs

## Setup Options

### Via Developer Studio

1. Navigate to **Create New Agent**.
2. Find the **Agent Config** section.
3. Select **Bring your own LLM** from the Provider dropdown.
4. Enter your **API URL**, **Model Name**, and **API Token**.

<Frame caption="Developer Studio — LLM provider configuration">
  <img src="https://mintcdn.com/trugen/amqXezd4sybYFS6J/images/byo-llm.png?fit=max&auto=format&n=amqXezd4sybYFS6J&q=85&s=116c367ad7071d3532ad9e7bff96516a" alt="Bring Your Own LLM configuration in Developer Studio" width="758" height="541" data-path="images/byo-llm.png" />
</Frame>

### Via API

Set `provider` to `"custom"` within the `avatars.config.llm` object:

<CodeGroup>
  ```bash Create Agent with Custom LLM theme={null}
  curl --request POST \
    --url https://api.trugen.ai/v1/ext/agent \
    --header 'Content-Type: application/json' \
    --header 'x-api-key: YOUR_API_KEY' \
    --data @- <<EOF
  {
    "agent_name": "Custom LLM Agent",
    "config": { "timeout": 240 },
    "avatars": [
      {
        "config": {
          "llm": {
            "provider": "custom",
            "model": "MODEL_NAME",
            "url": "API_BASE_URL",
            "token": "YOUR_EXTERNAL_TOKEN"
          },
          "stt": { "provider": "deepgram", "model": "nova-3" },
          "tts": { "provider": "elevenlabs", "voice_id": "ZUrEGyu8GFMwnHbvLhv2" }
        },
        "persona_name": "Custom LLM Agent",
        "persona_prompt": "You are a helpful AI agent."
      }
    ]
  }
  EOF
  ```
</CodeGroup>

## What's Next?

<CardGroup cols={2}>
  <Card title="Available LLMs" icon="brain" href="/docs/agents/available-llms">
    Browse all built-in models across Groq, Azure OpenAI, Google, and more.
  </Card>

  <Card title="Prompting Strategies" icon="pen" href="/docs/agents/prompting-strategies">
    Write effective system prompts for your custom LLM.
  </Card>
</CardGroup>
