-
Notifications
You must be signed in to change notification settings - Fork 9
feat: add submodule of worker-vllm, updated fastapi endpoints #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
velaraptor-runpod
wants to merge
13
commits into
main
Choose a base branch
from
feat/update-vllm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
123695f
feat: add submodule of worker-vllm, updated fastapi endpoints
velaraptor-runpod 621bea4
chore: update readme
velaraptor-runpod 5ed04e7
chore: update .runpod readme
velaraptor-runpod 6edea3c
Runpod not RunPod
velaraptor-runpod 08af673
update banner
velaraptor-runpod 7be7531
fix: add lmcache version, and astral version
velaraptor-runpod f0727a8
fix: cleaner error handling, ping states when engine is ready
velaraptor-runpod b1ecd74
remove github workflows for now, update submodule, update readme
velaraptor-runpod 082de35
fix: fix readme
velaraptor-runpod c7ce118
fix: python imports, consistent streaming check
velaraptor-runpod 3ea3255
fix: dockerfile lmcache in submodule now
velaraptor-runpod d21cd66
fix: update module
velaraptor-runpod 80c2332
fix: fix merge conflicts
velaraptor-runpod File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [submodule "worker-vllm"] | ||
| path = worker-vllm | ||
| url = https://github.com/runpod-workers/worker-vllm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,222 @@ | ||
|  | ||
|
|
||
| Run LLMs using [vLLM](https://docs.vllm.ai) with OpenAI-compatible and Anthropic-compatible APIs on Runpod's Load Balancer for high-throughput, multi-worker scalability. | ||
|
|
||
| Built on [worker-vllm](https://github.com/runpod-workers/worker-vllm) as the base inference engine. | ||
|
|
||
| --- | ||
|
|
||
| ## Endpoint Configuration | ||
|
|
||
| All behaviour is controlled through environment variables: | ||
|
|
||
| | Environment Variable | Description | Default | Options | | ||
| | ----------------------------------- | ------------------------------------------------- | ------------------- | ------------------------------------------------------------------ | | ||
| | `MODEL_NAME` | Path of the model weights | "facebook/opt-125m" | Local folder or Hugging Face repo ID | | ||
| | `HF_TOKEN` | HuggingFace access token for gated/private models | | Your HuggingFace access token | | ||
| | `MAX_MODEL_LEN` | Model's maximum context length | | Integer (e.g., 4096) | | ||
| | `QUANTIZATION` | Quantization method | | "awq", "gptq", "squeezellm", "bitsandbytes" | | ||
| | `TENSOR_PARALLEL_SIZE` | Number of GPUs | 1 | Integer | | ||
| | `GPU_MEMORY_UTILIZATION` | Fraction of GPU memory to use | 0.95 | Float between 0.0 and 1.0 | | ||
| | `MAX_NUM_SEQS` | Maximum number of sequences per iteration | 256 | Integer | | ||
| | `ENABLE_AUTO_TOOL_CHOICE` | Enable automatic tool selection | false | boolean (true or false) | | ||
| | `TOOL_CALL_PARSER` | Parser for tool calls | | "mistral", "hermes", "llama3_json", "granite", "deepseek_v3", etc. | | ||
| | `REASONING_PARSER` | Parser for reasoning-capable models | | "deepseek_r1", "qwen3", "granite", "hunyuan_a13b" | | ||
| | `OPENAI_SERVED_MODEL_NAME_OVERRIDE` | Override served model name in API | | String | | ||
| | `MAX_CONCURRENCY` | Maximum concurrent requests | 300 | Integer | | ||
|
|
||
| **Pass any vLLM engine arg** not listed above by setting an env var with the **UPPERCASED** field name (e.g. `MAX_MODEL_LEN=4096`, `ENABLE_CHUNKED_PREFILL=true`). The worker auto-discovers all `AsyncEngineArgs` fields from env. See the [vLLM engine args docs](https://docs.vllm.ai/en/latest/configuration/engine_args) for all available options. | ||
|
|
||
| For complete configuration options, see the [full configuration documentation](https://github.com/runpod-workers/worker-vllm/blob/main/docs/configuration.md). | ||
|
|
||
| ## API Endpoints | ||
|
|
||
| This worker exposes direct HTTP endpoints (no Runpod serverless wrapper). Use your endpoint URL directly: | ||
|
|
||
| ``` | ||
| https://<ENDPOINT_ID>.api.runpod.ai/ | ||
| ``` | ||
|
|
||
| | Path | Method | Description | | ||
| |------|--------|-------------| | ||
| | `/ping` | GET | Health check (204 = init, 200 = ready) | | ||
| | `/v1/models` | GET | List available models | | ||
| | `/v1/chat/completions` | POST | OpenAI chat completions | | ||
| | `/v1/completions` | POST | OpenAI text completions | | ||
| | `/v1/responses` | POST | OpenAI Responses API | | ||
| | `/v1/messages` | POST | Anthropic Messages API | | ||
|
|
||
| ### OpenAI-Compatible API | ||
|
|
||
| #### Chat Completions | ||
|
|
||
| ```bash | ||
| curl -X POST "https://<ENDPOINT_ID>.api.runpod.ai/v1/chat/completions" \ | ||
| -H "Authorization: Bearer $RUNPOD_API_KEY" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "model": "meta-llama/Llama-3.1-8B-Instruct", | ||
| "messages": [ | ||
| { "role": "system", "content": "You are a helpful assistant." }, | ||
| { "role": "user", "content": "What is the capital of France?" } | ||
| ], | ||
| "max_tokens": 100, | ||
| "temperature": 0.7 | ||
| }' | ||
| ``` | ||
|
|
||
| #### Chat Completions (Streaming) | ||
|
|
||
| ```bash | ||
| curl -X POST "https://<ENDPOINT_ID>.api.runpod.ai/v1/chat/completions" \ | ||
| -H "Authorization: Bearer $RUNPOD_API_KEY" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "model": "meta-llama/Llama-3.1-8B-Instruct", | ||
| "messages": [ | ||
| { "role": "user", "content": "Write a short story about a robot." } | ||
| ], | ||
| "max_tokens": 500, | ||
| "temperature": 0.8, | ||
| "stream": true | ||
| }' | ||
| ``` | ||
|
|
||
| #### Text Completions | ||
|
|
||
| ```bash | ||
| curl -X POST "https://<ENDPOINT_ID>.api.runpod.ai/v1/completions" \ | ||
| -H "Authorization: Bearer $RUNPOD_API_KEY" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "model": "meta-llama/Llama-3.1-8B-Instruct", | ||
| "prompt": "The capital of France is", | ||
| "max_tokens": 64, | ||
| "temperature": 0.0 | ||
| }' | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ### Anthropic Messages API | ||
|
|
||
| Compatible with the Anthropic SDK and Claude Code. Point `ANTHROPIC_BASE_URL` at your endpoint: | ||
|
|
||
| ```bash | ||
| export ANTHROPIC_BASE_URL=https://<ENDPOINT_ID>.api.runpod.ai/ | ||
| export ANTHROPIC_API_KEY=$RUNPOD_API_KEY | ||
| ``` | ||
|
|
||
| #### Messages (Non-Streaming) | ||
|
|
||
| ```bash | ||
| curl -X POST "https://<ENDPOINT_ID>.api.runpod.ai/v1/messages" \ | ||
| -H "Authorization: Bearer $RUNPOD_API_KEY" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "model": "meta-llama/Llama-3.1-8B-Instruct", | ||
| "messages": [ | ||
| { "role": "user", "content": "What is the capital of France?" } | ||
| ], | ||
| "max_tokens": 100 | ||
| }' | ||
| ``` | ||
|
|
||
| #### Messages (Streaming) | ||
|
|
||
| ```bash | ||
| curl -X POST "https://<ENDPOINT_ID>.api.runpod.ai/v1/messages" \ | ||
| -H "Authorization: Bearer $RUNPOD_API_KEY" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "model": "meta-llama/Llama-3.1-8B-Instruct", | ||
| "messages": [ | ||
| { "role": "user", "content": "Write a short story about a robot." } | ||
| ], | ||
| "max_tokens": 500, | ||
| "stream": true | ||
| }' | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Usage | ||
|
|
||
| Below are minimal `python` snippets to get started quickly. | ||
|
|
||
| > Replace `<ENDPOINT_ID>` with your endpoint ID and `<API_KEY>` with a [RunPod API key](https://docs.runpod.io/get-started/api-keys). | ||
|
|
||
| ### OpenAI SDK | ||
|
|
||
| ```python | ||
| from openai import OpenAI | ||
| import os | ||
|
|
||
| client = OpenAI( | ||
| api_key=os.getenv("RUNPOD_API_KEY"), | ||
| base_url=f"https://<ENDPOINT_ID>.api.runpod.ai/v1", | ||
| ) | ||
| ``` | ||
|
|
||
| `Chat Completions (Non-Streaming)` | ||
|
|
||
| ```python | ||
| response = client.chat.completions.create( | ||
| model="meta-llama/Llama-3.1-8B-Instruct", | ||
| messages=[{"role": "user", "content": "Explain quantum computing in simple terms"}], | ||
| temperature=0, | ||
| max_tokens=100, | ||
| ) | ||
| print(response.choices[0].message.content) | ||
| ``` | ||
|
|
||
| `Chat Completions (Streaming)` | ||
|
|
||
| ```python | ||
| stream = client.chat.completions.create( | ||
| model="meta-llama/Llama-3.1-8B-Instruct", | ||
| messages=[{"role": "user", "content": "Explain quantum computing in simple terms"}], | ||
| temperature=0, | ||
| max_tokens=100, | ||
| stream=True, | ||
| ) | ||
| for chunk in stream: | ||
| print(chunk.choices[0].delta.content or "", end="", flush=True) | ||
| ``` | ||
|
|
||
| ### Anthropic SDK | ||
|
|
||
| ```python | ||
| import anthropic | ||
| import os | ||
|
|
||
| client = anthropic.Anthropic( | ||
| api_key=os.getenv("RUNPOD_API_KEY"), | ||
| base_url=f"https://<ENDPOINT_ID>.api.runpod.ai/", | ||
| ) | ||
|
|
||
| response = client.messages.create( | ||
| model="meta-llama/Llama-3.1-8B-Instruct", | ||
| messages=[{"role": "user", "content": "Explain quantum computing in simple terms"}], | ||
| max_tokens=100, | ||
| ) | ||
| print(response.content[0].text) | ||
| ``` | ||
|
|
||
| ### Claude Code | ||
|
|
||
| ```bash | ||
| export ANTHROPIC_BASE_URL=https://<ENDPOINT_ID>.api.runpod.ai/ | ||
| export ANTHROPIC_API_KEY=$RUNPOD_API_KEY | ||
| claude --model <MODEL_NAME> | ||
| ``` | ||
|
|
||
| ## Compatibility | ||
|
|
||
| For supported models, see the [vLLM supported models documentation](https://docs.vllm.ai/en/latest/models/supported_models.html). | ||
|
|
||
| ## Documentation | ||
|
|
||
| - **[🚀 Deployment Guide](https://docs.runpod.io/serverless/vllm/get-started)** - Step-by-step setup | ||
| - **[📖 Configuration Reference](https://github.com/runpod-workers/worker-vllm/blob/main/docs/configuration.md)** - All environment variables | ||
| - **[🔧 Development Guide](https://github.com/runpod-workers/worker-vllm/blob/main/docs/conventions.md)** - Architecture and patterns | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.