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

# Model servers

export const Comments = ({children}) => {
  return <div class="my-4 px-5 py-4 overflow-hidden rounded-2xl flex gap-3 border border-zinc-500/20 bg-zinc-50/50 dark:border-zinc-500/30 dark:bg-zinc-500/10" data-callout-type="comments">
      <div class="w-4">
        <svg width="14" height="14" viewBox="0 0 640 640" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" aria-label="Comments">
            <path d="M320 112C434.9 112 528 205.1 528 320C528 434.9 434.9 528 320 528C205.1 528 112 434.9 112 320C112 205.1 205.1 112 320 112zM320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320C64 461.4 178.6 576 320 576zM280 400C266.7 400 256 410.7 256 424C256 437.3 266.7 448 280 448L360 448C373.3 448 384 437.3 384 424C384 410.7 373.3 400 360 400L352 400L352 312C352 298.7 341.3 288 328 288L280 288C266.7 288 256 298.7 256 312C256 325.3 266.7 336 280 336L304 336L304 400L280 400zM320 256C337.7 256 352 241.7 352 224C352 206.3 337.7 192 320 192C302.3 192 288 206.3 288 224C288 241.7 302.3 256 320 256z" />
        </svg>
      </div>
      <div class="text-sm prose min-w-0 w-full">
        {children}
      </div>
    </div>;
};

export const TroubleshootSolution = ({children}) => <>
    <hr className="my-3 w-full" />
    <details className="mt-3">
      <summary className="cursor-pointer font-semibold text-base mb-1">
        Solution
      </summary>
      <div className="mt-2 ml-4" data-component-part="step-content">
        {children}
      </div>
    </details>
  </>;

export const TroubleshootCause = ({children}) => <details className="mt-3 mb-2">
    <summary className="cursor-pointer font-semibold text-base mb-1">
      Cause
    </summary>
    <div className="mt-2 ml-4" data-component-part="step-content">
      {children}
    </div>
  </details>;

export const TroubleshootTitle = ({children}) => <>
    <p className="m-0 font-semibold text-xl leading-tight mb-2" role="heading" aria-level={3}>
      {children}
    </p>
    <hr className="my-3 w-full" />
  </>;

export const Troubleshoot = ({children}) => <div className="callout my-4 px-5 py-4 overflow-hidden rounded-2xl flex gap-3 border troubleshoot-admonition dark:troubleshoot-admonition" data-callout-type="troubleshoot">
    <div className="mt-0.5 w-4">
      <svg width="14" height="14" viewBox="0 0 640 640" fill="currentColor" className="w-4 h-4" aria-label="Troubleshoot">
        <path d="M541.4 162.6C549 155 561.7 156.9 565.5 166.9C572.3 184.6 576 203.9 576 224C576 312.4 504.4 384 416 384C398.5 384 381.6 381.2 365.8 376L178.9 562.9C150.8 591 105.2 591 77.1 562.9C49 534.8 49 489.2 77.1 461.1L264 274.2C258.8 258.4 256 241.6 256 224C256 135.6 327.6 64 416 64C436.1 64 455.4 67.7 473.1 74.5C483.1 78.3 484.9 91 477.4 98.6L388.7 187.3C385.7 190.3 384 194.4 384 198.6L384 240C384 248.8 391.2 256 400 256L441.4 256C445.6 256 449.7 254.3 452.7 251.3L541.4 162.6z" />
      </svg>
    </div>
    <div className="prose min-w-0 w-full">{children}</div>
  </div>;

Model servers let you run open-source large language models (LLMs) locally on your own machine and interact with them through API calls. You can create multiple named servers, each configured with its own model, address, port, API key, and model settings. This makes it easy to test different models or configurations in parallel without affecting other servers.

<Tip>
  Prefer working on the command line? Use the [Anaconda AI CLI](/docs/cli-reference/anaconda-ai/getting-started) to manage your servers.
</Tip>

## Creating a server

Model servers are the core component of Anaconda Desktop that enable you to interact with your locally downloaded LLMs through API calls. Follow these steps to create and configure your servers:

<Steps>
  <Step title="Open Model Servers">
    Select <Icon icon="server" iconType="regular" /> **Model Servers** from the left-hand navigation.
  </Step>

  <Step title="Create a server">
    Click <Icon icon="plus" iconType="light" /> **Create Server** in the top-right corner.

    <Frame>
      <img src="https://mintcdn.com/anaconda-29683c67/Aty9w0mqC-G2DD7s/images/anaconda-desktop/desktop_servers_list.png?fit=max&auto=format&n=Aty9w0mqC-G2DD7s&q=85&s=248c98140bbc6d1d51789fac6c393d2e" alt="Model Servers page showing an empty servers table and the Create Server button" width="3460" height="1870" data-path="images/anaconda-desktop/desktop_servers_list.png" />
    </Frame>
  </Step>

  <Step title="Configure the server">
    Fill in the fields in the **Create Server** dialog:

    * **Server Name**: A unique name to identify this server.
    * **Address**: The network address to bind to (default: `127.0.0.1`).
    * **Port**: The port to listen on (default: `8080`).
    * **API Key** (optional): A string used to authenticate requests. See [API key](#api-key) for details.
    * **Model Name**: Select the model and quantization level to load.
    * **Maximum Response Length**: The maximum number of tokens the model generates in a single response (0–2,048). Check **Let the model decide** to let the model determine when it has fulfilled the request.
    * **Context Length**: The maximum number of tokens the model can hold in memory at once, including the conversation history and the response being generated (0–8,192).
    * **Temperature**: Controls the randomness of the model's output (0–1). Lower values produce more deterministic responses; higher values produce more varied output.
    * **System Prompt**: Instructions that shape the model's behavior for every request.
    * **Enable vision (multimodal)**: Appears only when an `image-text-to-text` model is selected. When checked, the server starts with the downloaded multimodal projector (the model's vision component), enabling vision capabilities. When unchecked, the model runs in text-only mode.

    <Frame>
      <img src="https://mintcdn.com/anaconda-29683c67/Aty9w0mqC-G2DD7s/images/anaconda-desktop/desktop_server_create.png?fit=max&auto=format&n=Aty9w0mqC-G2DD7s&q=85&s=62abf6e523a69377bac9ade5df899091" alt="Create Server dialog showing server name, address, port, API key, model name, and model settings fields" width="3460" height="1736" data-path="images/anaconda-desktop/desktop_server_create.png" />
    </Frame>
  </Step>

  <Step title="Create the server">
    Click <Icon icon="plus" iconType="light" /> **Create**. The server appears in the **Servers** table.
  </Step>
</Steps>

<Troubleshoot>
  <TroubleshootTitle>
    ### Model won't load (exit code 3221225781)
  </TroubleshootTitle>

  <TroubleshootCause>
    The model you are trying to load requires a C++ runtime environment, but Microsoft does not include one in their operating systems by default.
  </TroubleshootCause>

  <TroubleshootSolution>
    Install the Latest [Microsoft Visual C++ Redistributable Version](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-microsoft-visual-c-redistributable-version).
  </TroubleshootSolution>
</Troubleshoot>

## Starting and stopping a server

To start a server, click the <Icon icon="ellipsis-vertical" iconType="regular" /> actions menu on the server's row and select <Icon icon="play" iconType="light" /> **Start**.

<Frame>
  <img src="https://mintcdn.com/anaconda-29683c67/Aty9w0mqC-G2DD7s/images/anaconda-desktop/desktop_server_actions.png?fit=max&auto=format&n=Aty9w0mqC-G2DD7s&q=85&s=f81b6c6ebdb5b685fc3e96bb886589dd" alt="Server row actions menu showing Start, Copy Code, Copy Address, View Details, and Delete options" width="3460" height="1790" data-path="images/anaconda-desktop/desktop_server_actions.png" />
</Frame>

The server's status updates to **Running** and live CPU/RAM usage appears in the row and in the status bar at the bottom of the page.

<Frame>
  <img src="https://mintcdn.com/anaconda-29683c67/Aty9w0mqC-G2DD7s/images/anaconda-desktop/desktop_server_running.png?fit=max&auto=format&n=Aty9w0mqC-G2DD7s&q=85&s=23ce8e832d8e36df1b080d167b48cddf" alt="Servers table showing a running server with CPU and RAM usage" width="3460" height="1820" data-path="images/anaconda-desktop/desktop_server_running.png" />
</Frame>

To stop a running server, click the <Icon icon="ellipsis-vertical" iconType="regular" /> actions menu and select <Icon icon="stop" iconType="light" /> **Stop**.

## Viewing server details

Once you've created a server, you can view and edit its details. To open a server's details page, click the server's row on the **Servers** table or click the <Icon icon="ellipsis-vertical" iconType="regular" /> actions menu on the server's row and select **View Details**. The detail page has two tabs: **Overview** and **Logs**.

The **Overview** tab shows four cards:

* **Details**: The server's address, API key, model, and unique server ID. Hover over the **ID** or **Address** fields and click <Icon icon="copy" iconType="light" /> **Copy** to copy their values for use in API requests. Click <Icon icon="pen" iconType="regular" /> **Edit** to modify the server configuration.
* **Code**: Ready-to-use connection code pre-filled with this server's address. The code varies by model and configuration. See [Connecting applications to servers](#connecting-applications-to-servers) for more information.
* **Model Settings**: The current values for Maximum Response Length, Context Length, Temperature, and System Prompt. Click <Icon icon="pen" iconType="regular" /> **Edit** to update these settings.
* **Usage Metrics**: Current-session RAM and CPU usage for the running server. See [Resource consumption](/docs/anaconda-desktop/resource-consumption) for more information.

<Note>
  You must [stop the server](#starting-and-stopping-a-server) before editing its details or model settings.
</Note>

The **Logs** tab shows the server log output. See [Viewing server logs](#viewing-server-logs) for details.

## Viewing server logs

The server records all incoming traffic and displays relevant information in the server logs. To view logs, open the server's [detail page](#viewing-server-details) and select the **Logs** tab.

The server logs record the following:

* **System information**: Provides information about your system's hardware capabilities.
* **Build information**: Provides information about the version of the server you are using.
* **Chat template**: Shows the sequence of messaging defined for the system.
* **Server listening**: Displays the server address and port number being listened to.
* **Slot information**: Displays the number of available slots for the server. Each slot is able to manage one user API request at a time.
* **Task information**: Displays information such as time spent processing and responding to a request, the request task ID, and which slot fulfilled the task.

After you stop the server, Desktop saves the log to the following location with a timestamped filename (for example, `<YYYY><MM><DD><HH><MM><SS>_api-server.log`), so you can efficiently locate specific server logs, if necessary:

<Tabs>
  <Tab title="Windows">
    For Windows machines, you can find the logs here: `C:\Users\<USERNAME>\AppData\Roaming\anaconda-desktop\logs`
  </Tab>

  <Tab title="macOS">
    For macOS machines, you can find the logs here: `~/Library/Logs/anaconda-desktop/`
  </Tab>
</Tabs>

## Understanding server settings

### Server address

Your local server address, often referred to as `localhost` or `127.0.0.1`, is the default address for model servers. It is a loopback address, meaning any network communication sent to this address remains within the same machine, keeping your data secure and private. This is common for developing applications.

<Tip>
  `localhost` and `127.0.0.1` are semantically identical.
</Tip>

If you are working in an office network and want to make your server accessible to other devices within the same network, you can set the server address to your machine's local IP address. These are typically private networks, meaning they're not routable on the public internet.

Setting the server address to `0.0.0.0` configures it to accept connections on all network interfaces. This can expose your server to the public internet if your network is configured to allow external connections and route traffic from external sources to your server.

### Server port

The server port tells the model server where to listen for incoming traffic (that is, where to listen and pick up API requests).

For more information, see [Cloudflare's article on ports](https://www.cloudflare.com/learning/network-layer/what-is-a-computer-port/).

<Tip>
  Your base URL for communicating with a server combines its address and port. For example, `http://127.0.0.1:8080/`. You can copy the URL directly from the **Address** column or by clicking the <Icon icon="ellipsis-vertical" iconType="regular" /> actions menu and selecting <Icon icon="link" iconType="light" /> *Copy Address*.
</Tip>

### API key

An API key is an optional string that must be passed as an `Authorization: Bearer` token in the header of requests made to your server. You can choose any unique string as the API key, but the value you set when creating the server must match what you use in the `Authorization: Bearer` header.

<Accordion title="Testing your API key">
  To test an API key:

  1. Select <Icon icon="server" iconType="regular" /> **Model Servers** from the left-hand navigation.

  2. Enter your API key in the **API Key** field.

  3. [Load a model into the API server](#creating-a-server).

       <Note>
         You must use a `text-generation` type model.
       </Note>

  4. Open <Tooltip tip="A command-line application included with Windows installations of Anaconda Distribution and Miniconda. Find it by searching 'Anaconda Prompt' in the Windows Start menu.">Anaconda Prompt</Tooltip> (Terminal on macOS/Linux) and run the following command:

       <CodeGroup>
         ```sh Anaconda Prompt theme={null}
         curl --request POST ^
             --url http://127.0.0.1:8080/completion ^
             --header 'Authorization: Bearer <API_KEY>' ^
             --header "Content-Type: application/json" ^
             --data '{
                 "prompt": "Hello, how are you?"
             }'
         ```

         ```sh Anaconda PowerShell Prompt theme={null}
         curl --request POST `
             --url http://127.0.0.1:8080/completion `
             --header 'Authorization: Bearer <API_KEY>' `
             --header "Content-Type: application/json" `
             --data '{
                 "prompt": "Hello, how are you?"
             }'
         ```

         ```sh Terminal  theme={null}
         curl --request POST \
             --url http://127.0.0.1:8080/completion \
             --header 'Authorization: Bearer <API_KEY>' \
             --header "Content-Type: application/json" \
             --data '{
                 "prompt": "Hello, how are you?"
             }'
         ```
       </CodeGroup>

       <Comments>
         Replace \<API\_KEY> with the API key you set when creating the server.
       </Comments>

  If you receive a response, your API key is working. If you receive a 401 error, double check your command or API key and try again.
</Accordion>

## Connecting applications to servers

Connecting your application to a model server requires setting two environment variables: the `base_url`, which directs your API calls to the server hosting your model, and the `api_key`, which authenticates your requests.

Follow the steps below to find these variables' values and save them as environment variables in your application.

<Steps>
  <Step title="Configure your server">
    From the **Model Servers** page:

    1. Note your **Server Address** and **Server Port** (the default is `http://localhost:8080`). This will be your `base_url`.
    2. (Optional) Set an **API Key**. You can use any unique string value. If you don't set an API key, you don't need to provide an `api_key` in your application.
    3. [Load a model](#creating-a-server) and click <Icon icon="play" iconType="solid" /> **Start**.
  </Step>

  <Step title="Configure your application">
    Set your credentials as environment variables:

    <CodeGroup>
      ```powershell Windows PowerShell theme={null}
      $env:MODEL_SERVER_BASE_URL="<BASE_URL>"
      $env:ANACONDA_API_KEY="<API_KEY>"
      ```

      ```bash macOS/ Linux terminal theme={null}
      export MODEL_SERVER_BASE_URL="<BASE_URL>"
      export ANACONDA_API_KEY="<API_KEY>"
      ```
    </CodeGroup>

    <Comments>
      Replace \<BASE\_URL> with the server address and port you copied from the **Model Servers** page.<br />
      Replace \<API\_KEY> with the API key you created on the **Model Servers** page.
    </Comments>

    <Note>
      Setting environment variables is considered a best practice for security. However, for local testing and development, you can add the credentials directly in your code instead.

      ***

      Environment variables set directly in the terminal will only last as long as the terminal session is active. To make these environment variables permanent, follow your system's standard process for persisting environment variables.
    </Note>
  </Step>
</Steps>

### OpenAI API compatibility

Anaconda Desktop model servers are OpenAI API compatible for chat completions. See OpenAI's [Chat Completion API documentation](https://developers.openai.com/api/reference/chat-completions/overview) for more information on making chat completion requests.

<Note>
  For production use, store the `base_url` and `api_key` values as environment variables rather than hardcoding them in your application.
</Note>

See OpenAI's [Chat Completion API documentation](https://developers.openai.com/api/reference/chat-completions/overview) for more information on making chat completion requests.
