Skip to main content
vLLM workers use the same request operations as any other Runpod Serverless endpoint, with specialized input parameters for LLM inference.

How vLLM requests work

vLLM workers are queue-based Serverless endpoints. They use the same /run and /runsync operations as other Runpod endpoints, following the standard Serverless request structure. The key difference is the input format. vLLM workers expect specific parameters for language model inference, such as prompts, messages, and sampling parameters. The worker’s handler processes these inputs using the vLLM engine and returns generated text.

Request operations

vLLM endpoints support both synchronous and asynchronous requests.

Asynchronous requests with /run

Use /run to submit a job that processes in the background. You’ll receive a job ID immediately, then poll for results using the /status endpoint.

Synchronous requests with /runsync

Use /runsync to wait for the complete response in a single request. The client blocks until processing is complete.
For more details on request operations, see Send API requests to Serverless endpoints.

Input formats

vLLM workers accept two input formats for text generation.

Messages format (for chat models)

Use the messages format for instruction-tuned models that expect conversation history. The worker automatically applies the model’s chat template.

Prompt format (for text completion)

Use the prompt format for base models or when you want to provide raw text without a chat template.

Applying chat templates to prompts

If you use the prompt format but want the model’s chat template applied, set apply_chat_template to true.

Request input parameters

Here are all available parameters you can include in the input object of your request.

Sampling parameters

Sampling parameters control how the model generates text. Include them in the sampling_params dictionary in your request.

Streaming responses

Enable streaming to receive tokens as they’re generated instead of waiting for the complete response.
For more information on streaming, see the stream operation documentation.

Error handling

Implement proper error handling to manage network timeouts, rate limiting, worker initialization delays, and model loading errors.

Best practices

Follow these best practices when sending requests to vLLM workers. Set appropriate timeouts based on your model size and expected generation length. Larger models and longer generations require longer timeouts. Implement retry logic with exponential backoff for failed requests. This handles temporary network issues and worker initialization delays. Use streaming for long responses to provide a better user experience. Users see output immediately instead of waiting for the entire response. Optimize sampling parameters for your use case. Lower temperature for factual tasks, higher temperature for creative tasks. Monitor response times to identify performance issues. If requests consistently take longer than expected, consider using a more powerful GPU or optimizing your parameters. Handle rate limits gracefully by implementing queuing or request throttling in your application. Cache common requests when appropriate to reduce redundant API calls and improve response times.

Next steps