opensourceprojects.dev

A broadsheet for software that doesn't ask for your email

Self-Host Any Open-Source LLM as an OpenAI-Compatible API with One Command
GitHub RepoImpressions3

Project Description

View on GitHub

One Command to Self-Host Any Open-Source LLM (OpenAI Compatible)

Let’s be honest: running a local LLM is often a pain. You spend more time wrestling with CUDA versions, tokenizers, and broken Python environments than actually using the model. Then, once you finally get it running, you realize your existing code expects an OpenAI API key.

What if you could spin up any major open-source model with a single command and have it speak the OpenAI API dialect natively?

That’s exactly what OpenLLM from BentoML does.

What It Does

OpenLLM is a Python framework that takes any supported open-source large language model (LLM) and wraps it into a production-ready REST API that mirrors the OpenAI API spec. Think of it as a universal adapter. You point it at a model (like Llama 3, Mistral, or Gemma), and it gives you back a /v1/chat/completions endpoint your existing apps can hit immediately.

The magic is in the single command. You don’t need to download weights manually or edit a config file. You just run:

pip install openllm
openllm start llama-3.2-1b-instruct

And in a few seconds, you have a local OpenAI-compatible server running on http://localhost:3000.

Why It’s Cool

Three things stand out.

First, no vendor lock-in. If you have code that talks to api.openai.com, you can swap the base URL to your local server and instantly switch to an open-source model. This is huge for staging environments, offline use, or simply testing multiple models without changing your codebase.

Second, it’s not just a toy. Under the hood, OpenLLM uses BentoML’s serving infrastructure. You get batching, adaptive batching, concurrency control, and metrics out of the box. This isn’t just a quick script – it’s built for actual traffic.

Third, wide model support. It supports the heavy hitters (Llama 3.1, Phi-3, Gemma 2, Qwen 2.5) and even some specialized ones like LWM (large world model) and StableLM. If it’s popular on Hugging Face, it’s probably supported.

How to Try It

Getting started takes two minutes. Make sure you have Python 3.8+ and a machine with some RAM (or GPU, for the bigger models).

  1. Install OpenLLM:

    pip install openllm
    
  2. Start a model. For a quick test, use a smaller one:

    openllm start phi-2-3b
    
  3. In a new terminal, send a curl request:

    curl http://localhost:3000/v1/chat/completions \
      -H "Content-Type: application/json" \
      -d '{
        "model": "phi-2-3b",
        "messages": [{"role": "user", "content": "Say this is a test!"}],
        "temperature": 0.7
      }'
    

You’ll get back an OpenAI-style response. To use it from a Python script with the openai library:

from openai import OpenAI

client = OpenAI(base_url="http://localhost:3000/v1", api_key="test")
response = client.chat.completions.create(
    model="phi-2-3b",
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)

For GPU acceleration, just add --device cuda to the start command. For the full list of models, run openllm models.

Final Thoughts

If you’re a developer who has ever wanted to quickly test an open-source model without rewriting your OpenAI integration, this is your tool. It does exactly one thing – serve models as a drop-in replacement – and does it well.

It’s not going to beat a dedicated, distributed inference server for massive traffic, but for personal use, team demos, or CI pipelines, it’s perfect. I’ve been using it to swap models during development without touching a line of business logic. That alone is worth the install.

Give it a shot. Your future self, debugging a production issue offline, will thank you.


@githubprojects

Back to Projects
Project ID: c880ab9d-81d0-42b5-95fd-27a647a8fcf1Last updated: July 27, 2026 at 06:31 AM