The OpenAI-compatible server¶
nvserve serve exposes a model over HTTP with the OpenAI API, so the official OpenAI SDKs,
LangChain, LlamaIndex, Open WebUI and other OpenAI-compatible tools work with it.
Point a client at http://127.0.0.1:8080/v1. The API key is not checked, so pass anything.
Options¶
| Option | Default | Meaning |
|---|---|---|
--host |
127.0.0.1 |
address to listen on; 0.0.0.0 makes it reachable from other machines |
--port |
8080 |
port |
--model-name |
file name | the model id reported by /v1/models |
--max-batch |
4 |
requests generated together; more wait in a queue (also capped by --mem-limit) |
--default-max-tokens |
256 |
max_tokens for requests that do not set it |
--no-think |
off | reasoning models answer directly unless a request asks for thinking |
--draft, --lookup, --draft-tokens |
off | speculative decoding for a lone request |
All the model options of run (--mem-limit, --ctx, --kv, --expert-cache,
--threads, ...) apply too. See the command-line reference.
No authentication
The server has no API keys and no TLS. Keep it on 127.0.0.1, or put it behind a reverse
proxy that adds authentication before exposing it to a network.
Chat completions¶
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8080/v1", api_key="unused")
reply = client.chat.completions.create(
model="model",
messages=[
{"role": "system", "content": "Answer in one sentence."},
{"role": "user", "content": "What is the capital of France?"},
],
max_tokens=64,
temperature=0,
)
print(reply.choices[0].message.content)
print(reply.usage)
Multi-turn conversations work by sending the whole history in messages, as with OpenAI.
Streaming¶
Set stream=True to receive tokens as server-sent events:
for chunk in client.chat.completions.create(model="model", messages=msgs, stream=True):
print(chunk.choices[0].delta.content or "", end="", flush=True)
Stop strings¶
stop takes one string or a list. Generation ends before the first match, and the match is
not included in the output:
Reasoning models¶
Qwen3 thinks before it answers. The server separates the two parts:
- the thinking goes into
message.reasoning_content(anddelta.reasoning_contentwhen streaming); - the answer goes into
message.content.
This is the convention vLLM and llama.cpp use. Thinking costs many tokens, and every token is a pass over the weights, so you can turn it off:
- for one request, with
"chat_template_kwargs": {"enable_thinking": false}(in the Python SDK, pass it throughextra_body); - for every request by default, with
--no-think(a request can still turn it back on).
Concurrent requests¶
Requests that arrive together share every pass over the weights, so the server's total
throughput grows with the number of active requests, up to --max-batch. Requests join and
leave between passes. A client that disconnects is cancelled at the next pass.
With --draft or --lookup, the server speculates while exactly one request is
generating. Concurrent requests share plain passes instead, and speculation resumes when
one request is left.
Health and models¶
curl http://127.0.0.1:8080/health # "ok"
curl http://127.0.0.1:8080/v1/models # the one model being served
The full list of supported request fields is in the HTTP API reference.