#66487·ray

[Serve] VLLM_API_KEY / engine api_key argument is not enforced by Ray Serve LLM OpenAI endpoints

Author: dhiedjaid-stackCreated Sep 25, 2026Updated Sep 30, 2026
Labelsservesecurityllmcommunity-backlog

Title: VLLM_API_KEY / engine api_key argument is not enforced by Ray Serve LLM OpenAI endpoints

Body:

What happened + What you expected to happen

When deploying a model with the vLLM Docker image directly (e.g., vllm/vllm-openai), setting either:

  • the --api-key CLI argument, or
  • the VLLM_API_KEY environment variable

causes the OpenAI-compatible endpoints to reject requests that do not include a matching Authorization: Bearer <key> header.

I expected the same behavior when using the ray-llm Docker image with ray.serve.llm, because:

  1. The LLMConfig/engine_kwargs API accepts vLLM engine arguments, including api_key.
  2. The runtime_env.env_vars block in serveConfigV2 can set VLLM_API_KEY.
  3. The documentation describes the resulting endpoint as OpenAI-compatible.

However, requests with an incorrect Authorization header or no header at all still reach the model and return completions. The variables are effectively no-ops for endpoint security.

Versions / Dependencies

  • Docker image: rayproject/ray-llm:2.58.0-py312-cu130
  • Ray: 2.58.0
  • vLLM (bundled): 0.26.0
  • Deployment entry points tested:
    • ray.serve.llm:build_openai_app
    • ray.llm._internal.serve.serving_patterns.data_parallel.builder:build_dp_openai_app

Reproduction

Deploy a RayService with serveConfig:

yaml
runtime_env:
  env_vars:
    VLLM_API_KEY: "my-secret-key"

or with engine_kwargs:

yaml
engine_kwargs:
  api_key: "my-secret-key"

Then call the endpoint with a wrong key:

bash
curl https://<ingress>/v1/chat/completions \
  -H "Authorization: Bearer wrong-key" \
  -H "Content-Type: application/json" \
  -d '{"model": "moonshotai/Kimi-K2.7-Code", "messages": [{"role": "user", "content": "hi"}]}'

Expected: HTTP 401 Unauthorized.

Actual: HTTP 200 with a model response.

Root cause

The vLLM OpenAI server installs an authentication middleware that validates Authorization against VLLM_API_KEY / --api-key. In contrast, the Ray Serve LLM builders create a separate FastAPI application (OpenAiIngress + LLMRouter) that routes requests to Ray Serve deployments. This FastAPI app:

  • Does not import or install vLLM's auth middleware.
  • Does not reference VLLM_API_KEY anywhere in the ingress or router code.

Because VLLM_API_KEY is forwarded only to the engine process (which does not inspect HTTP headers), there is no enforcement on the HTTP surface.

Request

Please make the Ray Serve LLM OpenAI endpoint respect the same authentication settings as the native vLLM server. Options:

  1. Preferred: When VLLM_API_KEY or api_key is configured, automatically install an Authorization Bearer-token check in the Ray Serve LLM ingress/router.

  2. Short-term: Document explicitly that VLLM_API_KEY/api_key are not enforced by ray.serve.llm and recommend ingress-level auth as the workaround.

Until this is fixed, deployments using ray-llm are left without built-in endpoint authentication.