bitsrun

Host a GGUF model as an OpenAI-compatible API

Host a GGUF model as an OpenAI-compatible API from Hugging Face or your own file. Pick a quant, deploy in minutes and call it with the OpenAI SDKs.

Updated

On this page

You have a GGUF model, on Hugging Face or on your own disk, and you want your app to call it the way it would call OpenAI. This guide shows how to host a GGUF model as an OpenAI-compatible API: pick the right quant, deploy it, and call it from Python or JavaScript. It takes about 10 minutes, plus the upload time if the file is on your disk.

What OpenAI-compatible means

An OpenAI-compatible API accepts the same requests, at the same paths, as the OpenAI API: POST /v1/chat/completions with a list of messages, /v1/completions, /v1/models. Any code or tool built for OpenAI works after you change two settings, the base URL and the API key. Your BitsRun endpoint answers at its own address, https://<endpoint-id>.endpoint.bitsrun.com/v1, where <endpoint-id> is the id shown on its card.

GGUF models run on llama.cpp. Because of that, they also answer Ollama's native paths (/api/chat, /api/generate) on the same host. See Use the API.

Before you start

  • A BitsRun account with credit (from $10). Create your account.
  • One of these: a Hugging Face GGUF repo, a link to one .gguf file, or a .gguf file on your computer.
  • The file must be a single file. Names that end in -00001-of-00003.gguf are split into parts and cannot be deployed yet.
  • For the terminal steps, the bitsrun command: curl -fsSL https://get.bitsrun.com | sh, then bitsrun login.

How to pick the right GGUF quant

A quant (quantization) is a smaller copy of the model that stores each number with fewer bits. Smaller files load faster and fit cheaper GPUs, with a small loss in quality.

QuantSize of an 8B modelQuality
Q4_K_Mabout 5 GBGood. The default
Q5_K_Mabout 6 GBBetter
Q6_Kabout 7 GBVery close to the original
Q8_0about 9 GBNear full quality

Start with Q4_K_M. If answers get careless with facts, numbers or code, try Q6_K or Q8_0. If a bigger model in Q4_K_M fits the same GPU as a smaller one in Q8_0, the bigger model usually wins. The file has to fit in GPU memory with room for the conversation: up to about 18 GB fits one NVIDIA L4 (24 GB), up to about 38 GB fits an L40S (48 GB). More in Quantization, and you can check any model in the VRAM calculator or read How much VRAM to run an LLM.

How to deploy a GGUF model

Pick the row that matches where your file is:

Your GGUF isType this as the modelNotes
In a Hugging Face repo with top-level quantshf:unsloth/Qwen3-8B-GGUF:Q8_0Leave off :Q8_0 to get Q4_K_M
One file on Hugging Facehttps://huggingface.co/owner/repo/blob/main/model-Q6_K.ggufUse this when the repo keeps files in folders
On your disk./my-model-Q4_K_M.ggufUploaded to your private storage first

From a Hugging Face repo

  1. Check it first. Nothing is created or billed:

    bash
    bitsrun size hf:unsloth/Qwen3-8B-GGUF:Q8_0

    You see the weights size, the GPU it fits and the context it supports.

  2. Deploy it with a key that works only with this endpoint:

    bash
    bitsrun deploy hf:unsloth/Qwen3-8B-GGUF:Q8_0 --name "Qwen3 8B Q8" --key

    You see the endpoint URL and an API key that starts with brk_. The key is printed once.

Do not type owner/repo without hf:. A name in that shape is read as an Ollama community model. In the dashboard, paste the same name or the model page link into Model on New endpoint, then select Check model and Create and start. See Copy the right name from Hugging Face.

  1. On Hugging Face, open Files and versions and select the .gguf file you want.

  2. Copy the page address. It contains /blob/main/.

  3. Deploy it:

    bash
    bitsrun deploy "https://huggingface.co/owner/repo/blob/main/model-Q6_K.gguf" --key

If the file sits in a folder or has an unusual name, BitsRun copies it into your storage first. That counts toward your model storage (10 GB free on Pay as you go, then $0.05 per GB a month).

From a file on your disk

  1. Upload and deploy in one step:

    bash
    bitsrun deploy ./my-model-Q4_K_M.gguf --key
  2. Wait for the upload and the check. The CLI sends 4 parts at a time and retries any part that fails.

You can also upload from the dashboard under Or upload your own model, then choose A GGUF file. Uploads stay in your private storage and nobody else can use them. Details in Upload your own model.

How to call a GGUF model with the OpenAI SDKs

Set your key once:

bash
export BITSRUN_API_KEY="brk_your_key"

Python

bash
pip install openai
python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://<endpoint-id>.endpoint.bitsrun.com/v1",
    api_key=os.environ["BITSRUN_API_KEY"],
)
stream = client.chat.completions.create(
    model="qwen3-8b-q8",
    messages=[{"role": "user", "content": "Explain GGUF in two sentences."}],
    max_tokens=300,
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

JavaScript or TypeScript

bash
npm install openai
javascript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://<endpoint-id>.endpoint.bitsrun.com/v1",
  apiKey: process.env.BITSRUN_API_KEY,
});
const reply = await client.chat.completions.create({
  model: "qwen3-8b-q8",
  messages: [{ role: "user", content: "Explain GGUF in two sentences." }],
  max_tokens: 300,
});
console.log(reply.choices[0].message.content);

The endpoint serves one model, so the model field can be any name. Pick one that reads well in your logs.

Does tool calling work with GGUF models?

Yes, when the model's chat template supports tools. Check before you deploy:

bash
bitsrun size hf:unsloth/Qwen3-8B-GGUF:Q8_0 --json

Look for "tools": true. Qwen3, Qwen2.5 Instruct, Llama 3.1 and newer, and Mistral instruct models generally support it. Then send tools, tool_choice and parallel_tool_calls as you would to OpenAI. A full example is in Tool calling.

How it compares to running llama-server yourself

llama.cpp ships its own server, llama-server, with OpenAI-compatible chat, completions and embeddings routes. Running it on your own GPU looks like this (llama-server README):

bash
llama-server -hf unsloth/Qwen3-8B-GGUF:Q8_0 --host 0.0.0.0 --port 8080 --api-key your-secret -c 32768

-hf downloads from Hugging Face (-m loads a local file instead), --host defaults to 127.0.0.1, --api-key turns on key checks and -c sets the context size.

llama-server on your own machineBitsRun
Enginellama.cppllama.cpp
GPU costYours, paid whether busy or idle$0.000264 a second on an L4 while awake, nothing while asleep
HTTPS, keys, revokingYou set up a proxy and TLS; keys are set when the server startsPer-app brk_ keys you can limit to one endpoint and revoke
UpkeepYou keep the machine and server patchedNo server for you to maintain
Flags and formatsEvery flag, split GGUFs, vision and moreSingle-file GGUF, text only, context up to 65,536 tokens
StartupAlways onA few seconds to about 40 seconds on a warm GPU, about 2 to 3 minutes on a new one, never billed

If you already own a GPU and need every flag, run llama-server. If you want an API that sleeps when idle and needs no server work, deploy it here.

How much does hosting a GGUF model cost?

You pay only while the endpoint is awake. One quick question on an L4 that answers in 20 seconds, then waits 2 minutes before sleeping:

(20 s + 120 s) x $0.000264 = $0.037

An office-hours assistant awake 8 hours a day for 22 working days costs 176 hours x $0.95 = $167.20 a month. Model it for your traffic in the cost calculator.

If something goes wrong

Message or codeWhat to do
model_split_unsupportedThe repo only has files split into parts. Pick a repo with single-file quants.
model_choose_fileThe repo keeps files in folders. Paste the link to one .gguf file.
model_quant_not_foundUse a quant the repo lists, or leave it empty for Q4_K_M.
model_too_largeChoose a smaller quant or a smaller model.
upload_not_gguf ("This file is not a valid GGUF model")Check that the file is a real .gguf export, not a renamed file.
401 unauthorizedSend Authorization: Bearer brk_... with a valid key.

All codes are on Error codes.

Create your account and deploy your first GGUF in a few minutes.

Frequently asked questions

Can I deploy a GGUF that is split into several files?

Not yet. Files named like -00001-of-00003.gguf are rejected with model_split_unsupported. Pick a repo that offers single-file quants instead.

Which quant should I choose?

Start with Q4_K_M, the default, which is hard to tell apart from the original for most chat use. Move to Q6_K or Q8_0 if answers get careless with facts, numbers or code.

Do I need to change my OpenAI code?

Only the base URL and the API key. Set the base URL to your endpoint address ending in /v1 and the key to your BitsRun key that starts with brk_.

Can I upload my own fine-tuned GGUF?

Yes. Upload one .gguf file from the dashboard or run bitsrun deploy ./my-model.gguf. It is stored privately in your account and counts toward your model storage.

Is tool calling supported?

Yes, for models whose chat template supports tools. Run bitsrun size <model> --json and look for "tools": true before you deploy.

Try it on your own model

Sign up with your email, add $10 of credit and deploy from an Ollama name or a Hugging Face repo. An L4 costs $0.95 an hour, billed per second only while your model is awake. Waking up is never billed, and credit you buy does not expire.