You will start a server that speaks the OpenAI chat API and call it from your own code. The vLLM template runs a model server on port 8000. Any tool that can talk to an OpenAI-style API can use it by changing its base address.
1. Deploy the server
- Open Deploy. Pick a GPU with VRAM of 16 GB or more, sorted by Price, low to high, and select Continue.
- Above the template cards, select the Language models filter. Select the vLLM (OpenAI-compatible) card, then Continue.
- Name the server
api-test. Under Environment variables, checkMODEL. The template sets it toQwen/Qwen2.5-1.5B-Instruct, a small public model. Keep it for the first run. - Select Continue, check Per hour and select Start my server.
You can also use Quick start and choose Serve a model as an API: it picks this template and the cheapest server in stock that fits.
At the time of writing the vLLM template does not run on RTX 50-series and other Blackwell GPUs; Deploy marks those configurations and you choose another GPU.
To serve another model, set MODEL to its Hugging Face name. MAX_MODEL_LEN (8192 by default) is the longest prompt plus answer, in tokens, the server accepts; a lower value needs less GPU memory. For a model that needs a login, add your Hugging Face token as HF_TOKEN and mark it as secret. The model must fit in the GPU memory; see the GPU memory guide.
2. Wait for the model
When the status is Running, open the server, select the Connect tab and copy the App address of port 8000. In the examples below it is SERVER_ADDRESS: the host and port, without http://. The server answers only after it has downloaded and loaded the model, which takes a few minutes the first time. Check from your own computer:
curl -i http://SERVER_ADDRESS/healthThe same tab shows the API key, generated for this server when it started (or the VLLM_API_KEY you set yourself, which the tab does not show). Press the eye button to see it. Every request must carry it, so use it wherever the examples below say YOUR_KEY. Under Try it from a terminal the tab also has a ready-made curl line; Copy with key copies it with your key filled in.
HTTP/1.1 200 OK means it is ready. Until then you see an error such as Connection refused; wait and try again. Now list the model name your requests must use:
curl http://SERVER_ADDRESS/v1/models \
-H "Authorization: Bearer YOUR_KEY"The answer contains "id":"Qwen/Qwen2.5-1.5B-Instruct".
3. Call it
With curl:
curl http://SERVER_ADDRESS/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_KEY" \
-d '{"model": "Qwen/Qwen2.5-1.5B-Instruct", "messages": [{"role": "user", "content": "Say hello in five words."}]}'With Python (pip install openai):
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-1.5B-Instruct",
messages=[{"role": "user", "content": "Say hello in five words."}],
)
print(reply.choices[0].message.content)With JavaScript (Node 18 or newer, npm install openai, save as chat.mjs, run node chat.mjs):
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "http://SERVER_ADDRESS/v1", apiKey: "YOUR_KEY" });
const reply = await client.chat.completions.create({
model: "Qwen/Qwen2.5-1.5B-Instruct",
messages: [{ role: "user", content: "Say hello in five words." }],
});
console.log(reply.choices[0].message.content);All three print a short greeting. Pass the key as api_key; the OpenAI libraries send it in the Authorization: Bearer header. Add "stream": true to get the answer piece by piece.
Keep it private
This server answers only requests that carry its API key; without it the answer is
401. Anyone who has the key can use the server, and the time they use is billed to you. Do not publish the key or put it in a public repository.
To keep the port closed to others, add an SSH key when you deploy and use a tunnel, with PORT and HOST from the SSH command on the Connect tab. Then use http://localhost:8000/v1 as the base address:
ssh -N -L 8000:localhost:8000 -p PORT root@HOSTFor an API with your own API key and no idle cost, use a serverless endpoint instead: Scale to zero with a serverless endpoint.
When you are done: stop or delete
- Stop ends the compute charge. The disk with the downloaded model is kept and still charged. After Start, the Connect tab shows the new address.
- Destroy ends every charge and deletes the disk. See Start, stop and restart.
Next
Ready to try it?
Create a free account and add credit when you want to start a server. The smallest top-up is $10.
Was this helpful?