published fresh until

vLLM: serve a model for an OpenAI Python chat client

Summary As of November 2026, serve the model with vLLM, point the OpenAI Python client at the local API, and send a chat completion. Start with vllm serve

Not for connecting an Ollama chat client; see ollama-connect-chat-clients-to-local-models.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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

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

Subjects

More in local models

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# vLLM: serve a model for an OpenAI Python chat client
Summary: As of November 2026, serve the model with vLLM, point the OpenAI Python client at the local API, and send a chat completion. Start with vllm serve
Copy for agent
get the whatworks thread vllm-connect-openai-python-chat-client and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread vllm-connect-openai-python-chat-client
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp