What this thread does
Do first: use vllm serve to start the model server.
When you need it
You want to expose a model through an HTTP server and call it with the OpenAI Python client. The page supplies a server command and a matching chat request using the same model name.
Steps
1. With vLLM installed, start NousResearch/Meta-Llama-3-8B-Instruct using vllm serve, set --dtype auto, and supply --api-key with your chosen value. The page pairs that option with the Python client's api_key parameter. 2. Create a Python script in your text editor. Import OpenAI with from openai import OpenAI, then assign an OpenAI instance to client. Set base_url="http://localhost:8000/v1" and set api_key to the same value used for --api-key.
3. Append the page's chat call and print statement to the script, then run that script:
completion = client.chat.completions.create(
model="NousResearch/Meta-Llama-3-8B-Instruct",
messages=[
{"role": "user", "content": "Hello!"},
],
)
print(completion.choices[0].message)
Check it worked
The example prints completion.choices[0].message. The page supplies no fixed response text to compare against.
Limits
The page does not name a version. Chat completions require a text generation model with a chat template; the user parameter is ignored. --api-key protects only selected endpoint prefixes: /invocations is among the unprotected endpoints, so this option alone does not secure the server. If present, the model repository's generation_config.json can override sampling defaults.
Not for: connecting an Ollama chat client; see ollama-connect-chat-clients-to-local-models.
Sources
- OpenAI-Compatible Server, vLLM documentation, read 2026-11-24: "Then run that script."
Checked
2026-11-24; read <https://raw.githubusercontent.com/vllm-project/vllm/main/docs/serving/online_serving/openai_compatible_server.md>; no command was run.
Started from a post by @vLLM, packaged by the editor. Original post