Tiny Python helper that provisions a Coder vLLM workspace and hands back an OpenAI-compatible endpoint + auth headers. Designed to drop into scripts, notebooks, evals, or services so you don't have to think about workspace lifecycle, token minting, or readiness probes.
from openai import OpenAI
from coder_vllm_bootstrap import bootstrap
endpoint, headers = bootstrap("Qwen/Qwen2.5-7B-Instruct")
client = OpenAI(base_url=endpoint, api_key="not-needed", default_headers=headers)
print(client.chat.completions.create(
model="Qwen/Qwen2.5-7B-Instruct",
messages=[{"role": "user", "content": "hi"}],
).choices[0].message.content)What bootstrap() does:
- Mints a fresh 1h Coder API token via the local
coderCLI. - Resolves the current Coder username (used in the workspace subdomain).
- Ensures the named workspace exists (creates with the configured template if missing, starts if stopped, no-op if running).
- Polls the public
/v1/modelsendpoint until vLLM responds. - Returns
(endpoint, headers)ready to plug into any OpenAI-compatible client.
- Python 3.9+
- The
coderCLI onPATH, authenticated to your Coder server (coder login <url>). - A Coder server with a vLLM-capable template (the matching Terraform template ships parameter names
model,extra_args,vram_budget_gb).
pip install coder-vllm-bootstrapConfiguration is via environment variables. The library does not load .env files itself — use python-dotenv or your shell of choice.
Required:
| Var | Description |
|---|---|
CODER_URL |
Base URL of your Coder server (any deployment). |
CODER_WORKSPACE |
Workspace name to provision / reuse. |
Optional (defaults shown):
| Var | Default | Effect |
|---|---|---|
CODER_TEMPLATE |
vllm |
Coder template name used when creating. |
CODER_APP_NAME |
vllm |
App subdomain prefix in the workspace URL: <APP>--<workspace>--<owner>.<host>. |
BOOTSTRAP_TOKEN_NAME |
vllm-bootstrap |
Prefix for the minted Coder API token (timestamp suffix is appended). |
VRAM_BUDGET_GB |
60 |
Forwarded to the template's vram_budget_gb parameter. |
VLLM_EXTRA_ARGS |
--max-model-len 8192 --max-num-seqs 8 |
Forwarded to the template's extra_args parameter. |
from dotenv import load_dotenv
from coder_vllm_bootstrap import bootstrap
load_dotenv() # reads .env from cwd
endpoint, headers = bootstrap("google/gemma-4-E4B-it")A sample .env:
CODER_URL=https://coder.example.com
CODER_WORKSPACE=my-vllm
VRAM_BUDGET_GB=16
VLLM_EXTRA_ARGS=--max-model-len 8192 --max-num-seqs 8 --quantization fp8- Tokens are short-lived (1h) and minted fresh on every
bootstrap()call. They auto-expire — no cleanup needed. - Workspace creation can take 1–10 minutes depending on model size and quantization. The
_wait_for_vllmpoll has a 10-minute deadline. - This library does not manage GPU contention. If your Coder host runs one workspace at a time per GPU, you're responsible for stopping conflicting workspaces before calling
bootstrap(). - The workspace-listing filter checks both
nameandtemplate_name, so two workspaces with the same name but different templates won't collide.
The Coder template referenced by CODER_TEMPLATE must:
- Accept three workspace-creation parameters:
model,extra_args,vram_budget_gb. - Publish a
coder_appwhose slug matchesCODER_APP_NAME, exposing the OpenAI-compatible API on the workspace's wildcard subdomain.
A reference template that satisfies both is here.
MIT — see LICENSE.