> For the complete documentation index, see [llms.txt](https://interworky.gitbook.io/interworky-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://interworky.gitbook.io/interworky-docs/getting-started/lm-studio-self-hosted-llm.md).

# LM Studio (Self Hosted LLM)

Bring Your Self-Hosted LM Studio LLM to Life with Interworky

With Interworky, you can seamlessly integrate your self-hosted LM Studio LLM into any website and bring your AI Agent to life.&#x20;

This tutorial will guide you through the setup process, integration steps, and testing of your Agent.

### **Step 1: Create an Interworky Account**

1\. Visit [interworky.com/setup-account](https://interworky.com/setup-account).

2\. Follow the on-screen instructions to create your account.

{% hint style="info" %}
&#x20;If you don’t have a website yet, you can use `example.com` as a placeholder during the setup process.
{% endhint %}

### **Step 2: Add Your LM Studio Configuration**

1\. Log in to your Interworky account and navigate to the Dashboard.

2\. Go to the Account Settings section

<figure><img src="https://3900551154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh8KeqaWePL624uIZ0FlH%2Fuploads%2Fusk8GYIipb24gwp0GDnm%2FAccountSettings-LMStudio.png?alt=media&amp;token=324a9a52-df17-4cda-be57-2e4a85dc314f" alt="" width="165"><figcaption><p> Account Settings in the Sidebar</p></figcaption></figure>

3\. Add the following details:

* LM Studio Hosted URL: This is your LM Studio server’s endpoint.&#x20;
  * For example:
    * If your server is hosted on a domain: <http://yourdomain.com/**v1/chat/completions>\*\*.

{% hint style="info" %}
If running locally, see the “[Running Locally](#running-locally-note-for-locally-hosted-servers)” note below.
{% endhint %}

* Model Name: Specify the model name of your LM Studio instance (e.g., llama-3.2-3b-instruct).
* System Message: Enter the default system message for your Agent.

<figure><img src="https://3900551154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh8KeqaWePL624uIZ0FlH%2Fuploads%2FxuoCXlFaxjZKpM8wEtQJ%2FLMStudio-ModelName.png?alt=media&amp;token=7f3cf6cf-f139-45b7-b88f-a9f20ace503c" alt=""><figcaption><p>LM Studio Model Name</p></figcaption></figure>

4. Click Save to store your configuration.

* Example Data:
  * LM Studio Hosted URL : `https://myllmwebsite.com/v1/chat/completions`
  * Model Name: `llama-3.2-3b-instruct`
  * System Message: `Respond in a funny quirky way and use metadata attached to understand the user`&#x20;

### **Step 3: Integrate Your Agent on a Website**

1. Navigate to the Integration Tab in your Interworky Dashboard.
2. Copy the script embed provided for your agent.
3. Add the script to the \<head> or \<body> section of the website where you want your agent to appear.
4. For platform-specific integration tutorials (e.g., WordPress, Squarespace), refer to the [Integration Tutorials](/interworky-docs/integration/integration-to-wordpress-websites.md)

### **Step 4: Test Your AI** agent **(Optional)**

1. Go to the AI agent Customization tab in your Interworky Dashboard.
2. Use the Test agent button to test your configuration before integrating it into your website

{% hint style="success" %}
This ensures that your LM Studio URL, model, and system message are working as expected.
{% endhint %}

### **Running Locally** (Note for Locally Hosted Servers)

**Running Locally with Ngrok**

If your LM Studio server is running locally, you can expose it to the internet using Ngrok, allowing your production server or other external users to access it.<br>

**Steps to Set Up Ngrok**

1\. Install Ngrok:

* Download and install Ngrok from the [official website](https://ngrok.com/download).
* After installation, authenticate your Ngrok account and expose your local server

`ngrok http 1237 #if your server is running on port is 1237`&#x20;

2. Capture your ngrok ip address

<figure><img src="https://3900551154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh8KeqaWePL624uIZ0FlH%2Fuploads%2FLGnt7Pb406jjZVhr0tnv%2Fngrok-forwarding%20address.png?alt=media&amp;token=047d9a26-1816-4fd0-8685-fcafe40d0e8b" alt=""><figcaption><p>Ngrok Forwarding IP Address</p></figcaption></figure>

3. Ensure CORS  and Serve on Local Network are enabled in you LM Settings

<figure><img src="https://3900551154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh8KeqaWePL624uIZ0FlH%2Fuploads%2FEd6pNq4sdO134Rwf9oK2%2Flm-studio-interworky.png?alt=media&amp;token=93d13539-2101-45e7-b388-91b37c203b8c" alt="" width="375"><figcaption><p>Ensure CORS  and Serve on Local Network are enabled in you LM Settings</p></figcaption></figure>

4. Update your LM Studio End Point in Interworky Account Settings

<figure><img src="https://3900551154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh8KeqaWePL624uIZ0FlH%2Fuploads%2Fnt0r9HgA7nkg5qQC7Ibh%2FScreenshot%202025-01-21%20at%2011.59.21%E2%80%AFAM.png?alt=media&amp;token=3955c0bb-766a-4636-81aa-1a75684ab86b" alt="" width="375"><figcaption><p>ADD LM Studio Url to Account Settings</p></figcaption></figure>

And Voila :tada:  You can chat with your self hosted LM Studio model on any website

<figure><img src="https://3900551154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh8KeqaWePL624uIZ0FlH%2Fuploads%2FeEHOzgema1uJONv5xyue%2FInterworkyChat-LMStudio.png?alt=media&amp;token=cccb3f8c-89a5-437b-b5a6-55fb61cf874d" alt="" width="375"><figcaption><p>Example of Interworky working with LM Studio self hosted Model</p></figcaption></figure>
