How to Easily Share LM studio API Online
Updated on Feb 19, 2025 · 4 mins read
In the era of generative AI, developers are continually seeking ways to quickly deploy and share their AI models without relying on complex cloud infrastructures. LM Studio offers a seamless experience to download, install, and run AI models locally, while tools like Pinggy enable you to expose your local endpoints to the internet securely. This guide provides a step-by-step tutorial on sharing your LM Studio API online, making your AI models accessible and shareable in minutes.

Summary
-
Download & Install LM Studio
- Visit LM Studio and download the installer for your operating system.
- Install LM Studio, launch the application, and navigate to the Discover tab.
- Download the model you want to use and share its API online.
-
Enable the Model API
- Go to the Developer tab.
- In the top-left corner, change the status from Stop to Run (your model will now be accessible at
http://localhost:1234
). - Copy the provided curl command and test it using Postman.
-
Expose Your API with Pinggy
- Create a secure tunnel using the following command:
ssh -p 443 -R0:localhost:1234 a.pinggy.io
- Share the generated public URL for easy access to your API.
- Create a secure tunnel using the following command:
Why Share Your LM Studio API Online?
Empowering Your AI Projects
By sharing your LM Studio API online, you can:
- Collaborate Remotely: Allow team members, clients, or stakeholders to access your AI model remotely.
- Integrate Seamlessly: Embed your model’s API into web or mobile applications without deploying to the cloud.
- Rapid Prototyping: Quickly demonstrate AI capabilities in demos & prototypes.
- Reduce latency by keeping inference local while enabling remote access.
Leveraging Pinggy for Secure Tunneling
Pinggy provides a hassle-free solution for exposing your local API to the public internet without the need for complex infrastructure. Key benefits include:
- Free HTTPS URLs: Secure, public URLs without additional installation overhead.
- No Bandwidth Limits: Enjoy unrestricted access, even on the free tier.
- Bandwidth-Friendly: With options like the Pinggy Pro plan, you can scale your usage as needed.
- Integrated Debugger: Monitor and troubleshoot requests with Pinggy’s web-based debugger.
Step-by-Step Guide to Sharing LM Studio API
Step 1: Download and Install LM Studio
-
Visit the Website:
Go to LM Studio and download the installer appropriate for your operating system (Windows, macOS, or Linux). -
Install LM Studio:
Follow the installation prompts to set up LM Studio on your machine. -
Launch and Download a Model:
- Open LM Studio and navigate to the Discover tab.
- Browse through the available models and download the one you want to use.
- Once downloaded, you are ready to share its API online.

Step 2: Enable Your Model API
-
Open the Developer Tab:
Click on the Developer tab located in LM Studio. -
Start Your API Server:
- At the top-left corner, you’ll see the status button.
- Change the status from Stop to Run.
This will launch your model’s API server onhttp://localhost:1234
.
-
Test the API Endpoint:
Below the status button, you will see a list of supported endpoints. Copy the displayedcurl
command and test it using a tool like Postman .Example Curl Command:
curl http://localhost:1234/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "qwen2-0.5b-instruct", "messages": [ { "role": "system", "content": "Always answer in rhymes. Today is Thursday" }, { "role": "user", "content": "What day is it today?" } ], "temperature": 0.7, "max_tokens": -1, "stream": false }'

Step 3: Expose Your LM Studio API via Pinggy
-
Set Up a Secure Tunnel:
While your LM Studio API is running onhttp://localhost:1234
, open your terminal and execute the following command to create a secure tunnel:ssh -p 443 -R0:localhost:1234 a.pinggy.io
-
Share the Public URL:
Once connected, Pinggy will generate a public URL (e.g.,https://xyz123.pinggy.link
). Share this URL to allow remote access to your API.
Advanced Tips and Best Practices
Secure Your API
-
Enable Basic Authentication:
To secure your tunnel, modify your SSH command to include a username and password:ssh -p 443 -R0:localhost:1234 -t a.pinggy.io b:username:password
This ensures that only authorized users can access your public URL.
-
Regular Monitoring:
Use Pinggy’s web debugger to keep an eye on incoming requests and identify any potential issues quickly.
Custom Domains and Performance Optimization
-
Custom Domain Setup:
With Pinggy Pro, you can map a custom domain to your tunnel, enhancing your branding and credibility. -
Performance Considerations:
For high-traffic applications, consider optimizing your LM Studio configuration and ensuring your local machine has sufficient resources to handle the load.
Troubleshooting
Common Issues and Fixes
-
Model Fails to Start:
- Check system requirements (RAM, CPU, etc.) and ensure your model is compatible with your hardware.
- Review LM Studio logs for any error messages.
-
Connection Timeouts
- Use Pinggy’s TCP mode for unstable networks:
Note: This command requires Pinggy Pro.
while true; do ssh -p 443 -o StrictHostKeyChecking=no -R0:localhost:3000 a.pinggy.io; sleep 10; done
- Incorrect API Response:
- Validate your curl command syntax.
- Confirm that LM Studio is correctly configured to serve the intended endpoints.
Conclusion
Combining LM Studio intuitive model deployment with Pinggy’s secure tunneling offers a streamlined approach to sharing your AI models online. This solution empowers developers to test, demo, and integrate AI capabilities without the overhead of cloud infrastructure, while keeping full control over data and performance.