Skip to main content
Apidly Cloud
Cookie policy

Analytics and ad cookies stay off unless you accept. Cookie policy

We would like to use Google Analytics and Microsoft Clarity to understand how the public pages are used, including page views and session recordings, and the Reddit Pixel to measure whether our ads on Reddit lead to visits and sign-ups. You choose here whether they are on. Rejecting changes nothing about how the site works.

Run an open LLM with vLLM on a rented GPU

Serve Qwen or another open model behind an OpenAI-compatible API on a rented GPU with vLLM: pick the GPU, set the model, call it from code and stop when idle.

Published November 25, 20265 min read

vLLM is a model server built for throughput. Start it on a rented GPU and you get an API that speaks the same protocol as the common hosted chat APIs, so existing code and tools work after you change one address. This guide shows how to start it with a model such as Qwen, how to choose a GPU, how to call it, and how to keep the bill small.

Why a rented GPU for this

You get an endpoint you control: your prompts go to your own server, you choose the model, and you pay by the second only while the server runs. There is nothing to install on your own computer. The trade-off is that you manage uptime and cost yourself, which this guide covers.

Step 1: Estimate the memory

The model weights must fit in GPU memory (VRAM), with room left for the cache vLLM keeps for each request. A quick estimate:

  • At 16-bit, about 2 GB per billion parameters. An 8B model is about 16 GB of weights.
  • Add 20 to 30 percent for the framework and cache, more for long prompts or many users at once.

So an 8B model at 16-bit wants a 24 GB GPU, such as the RTX 4090 or RTX 3090. A 14B model wants 32 GB or more, and a 70B model needs 48 GB even at 4-bit, or several GPUs at 16-bit. How much VRAM do you need? goes through the maths with examples.

Step 2: Pick a template

Apidly has several vLLM templates:

  • vLLM (OpenAI-compatible) starts vLLM with a model you choose through an environment variable. Its default is the small Qwen2.5-1.5B-Instruct so a first test is quick and cheap. It needs at least 16 GB.
  • Other model servers, such as Ollama and Text Generation Inference, are in the templates list if you prefer a different tool.

Start with vLLM if you want an OpenAI-style API and to choose the model yourself: start a vLLM server.

Step 3: Deploy

  1. Open Deploy, sort by Price, low to high and filter by the VRAM you estimated.
  2. Pick the vLLM (OpenAI-compatible) template.
  3. Under Environment variables, set MODEL to a Hugging Face model name, for example Qwen/Qwen2.5-7B-Instruct. Set MAX_MODEL_LEN to the longest prompt plus answer you need, in tokens. A lower value needs less memory for the cache.
  4. For a model that asks you to accept a licence, add your Hugging Face token as HF_TOKEN and mark it secret. See Secrets.
  5. On the review step check the Per hour price and select Start my server.

At the time of writing the template does not run on RTX 50-series and other Blackwell GPUs. Deploy marks those, so choose another GPU.

Step 4: Wait for the model to load

The server is billed from Running, but the API answers only after vLLM has downloaded and loaded the model. That takes a few minutes the first time, longer for bigger models. Open the server, go to the Connect tab, copy the address of port 8000 and the API key, and check:

curl -i http://SERVER_ADDRESS/health

200 OK means it is ready. Connection refused means keep waiting. If it never becomes ready, read If a server fails to start for the usual causes, such as a model that does not fit or a missing access token.

Step 5: Call it

The key on the Connect tab is generated for your server. Send it as a bearer token.

curl http://SERVER_ADDRESS/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_KEY" \
  -d '{"model": "Qwen/Qwen2.5-7B-Instruct", "messages": [{"role": "user", "content": "Give me three names for a coffee shop."}]}'

From Python with the openai package, only the base address and key change:

from openai import OpenAI

client = OpenAI(base_url="http://SERVER_ADDRESS/v1", api_key="YOUR_KEY")
reply = client.chat.completions.create(
    model="Qwen/Qwen2.5-7B-Instruct",
    messages=[{"role": "user", "content": "Give me three names for a coffee shop."}],
)
print(reply.choices[0].message.content)

The model value must match the name from GET /v1/models. Any tool that lets you set a custom base address, such as a chat front end or an agent framework, works the same way. The step-by-step vLLM API tutorial also shows JavaScript.

Step 6: Fix the usual problems

  • Out of memory when loading. The weights plus cache do not fit. Lower MAX_MODEL_LEN, choose a smaller or 4-bit quantised model, or use a GPU with more VRAM.
  • Gated model error. Accept the licence on the model's page, then add your token as HF_TOKEN.
  • Slow first request. The model is warming up. Later requests are faster.
  • Requests are refused. Check that you send the key. Never put the key in code you publish.

Step 7: Stop paying when you are not using it

A model server idles quietly and still costs the same per second. Use the tools that exist for this:

  • Stop the server when you finish. Compute billing ends; the disk with the downloaded model stays, so the next start is faster.
  • Add an Automation rule on the server: stop after a running time, stop when the GPU has been idle for a number of minutes, or stop at a spending limit. You get an email when a rule acts. See Automation.
  • Watch Billing for what each server cost, and set a monthly budget. Control costs shows how.

Billing is per second, so short experiments are cheap. For the exact rules, read Billing by the second, explained, and check live pricing for current rates, which change with supply.

If you need scale-to-zero instead

A dedicated server fits steady use. If traffic is rare and spiky, a serverless endpoint that starts workers on demand may suit you better; see Serverless. For choosing hardware more broadly, read How to pick a GPU for LLM inference, and see the LLM inference use case.

Try what this guide shows

Start one of these templates on a rented GPU server. You see the price per hour before you start, and you pay by the second.

Try it on a real GPU server

Create a free account and add a balance from $10. Servers are billed by the second, and the review step shows the price per hour before you request one.

Related guides