A vLLM server on your own machine needs no key, but the moment it is reachable by anyone else it does. vLLM takes an API key from the --api-key flag or the VLLM_API_KEY environment variable, and it accepts several keys at once — which is how you rotate a key without downtime.
Start with a key, then rotate by listing two
Start the server with a key: vllm serve Qwen/Qwen2.5-1.5B-Instruct --api-key token-abc123. Clients then send it as a bearer token in the Authorization header. To rotate, restart the server listing both the old and the new key; the server accepts any key passed, which the docs say is useful for key rotation. Move clients to the new key, then restart with only the new key.
vllm serve Qwen/Qwen2.5-1.5B-Instruct --api-key token-abc123
# rotate: accept both keys, then drop the old one
vllm serve Qwen/Qwen2.5-1.5B-Instruct --api-key token-abc123 --api-key token-xyz789
# clients send: Authorization: Bearer token-xyz789
Do not rely on the API key alone to secure vLLM: the docs warn the key only authenticates endpoints under /v1, /v2, /inference and /cohere, and other endpoints on the same server — most notably /invocations — are not authenticated. Put the server behind a reverse proxy or firewall as well, and never expose it to the internet unprotected.
Try it: four checks
| Check | What you should see | If you do not see it |
|---|---|---|
| Key required | A request without the key is rejected | Check the flag was passed at server start |
| Key works | A request with the bearer token succeeds | Check the Authorization header spelling |
| Both keys work | Old and new keys are both accepted during rotation | List both keys after –api-key |
| Old key dead | After the final restart the old key is rejected | Restart with only the new key |
Expected result. We checked the vLLM OpenAI-Compatible Server docs and Quickstart, which give the –api-key flag, the VLLM_API_KEY variable, multiple keys for rotation, and the warning that the key does not protect /invocations. We did not run vLLM on this machine.
Limits
This guide covers the API key only. The key is not full security: unauthenticated endpoints and network exposure need a proxy or firewall too. We did not test any of this ourselves.
