ワンクリックで
vllm-api
Use OpenAI-compatible API, integrate with clients
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use OpenAI-compatible API, integrate with clients
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Contribution guide, model integration, debugging
Distributed inference, tensor/pipeline parallelism
Multi-hardware backend configuration (CUDA, ROCm, NPU, XPU, CPU)
Text model inference (Llama, Qwen, Mistral, GPT, etc.)
LoRA adapter serving, multi-LoRA deployment
Vision, audio, and video model inference
| name | vllm-api |
| description | Use OpenAI-compatible API, integrate with clients |
| triggers | ["When user wants to call vLLM via API","When user needs OpenAI-compatible endpoints","When user wants to integrate vLLM with existing applications","When user encounters API authentication or error handling issues"] |
vLLM provides an OpenAI-compatible API server, enabling seamless integration with existing OpenAI clients and tools. This skill covers endpoint usage, client integration, and error handling.
pip install vllm)openai library, curl, or HTTP client)# Basic server
vllm serve meta-llama/Llama-2-7b-chat-hf
# With custom settings
vllm serve meta-llama/Llama-2-7b-chat-hf \
--host 0.0.0.0 \
--port 8000 \
--api-key your-api-key
Python Client:
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="dummy" # Required but ignored if not configured
)
response = client.chat.completions.create(
model="meta-llama/Llama-2-7b-chat-hf",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is machine learning?"}
],
temperature=0.7,
max_tokens=150
)
print(response.choices[0].message.content)
cURL:
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "meta-llama/Llama-2-7b-chat-hf",
"messages": [
{"role": "user", "content": "Hello!"}
],
"max_tokens": 50
}'
response = client.completions.create(
model="meta-llama/Llama-2-7b-chat-hf",
prompt="Once upon a time",
max_tokens=100,
temperature=0.8
)
print(response.choices[0].text)
stream = client.chat.completions.create(
model="meta-llama/Llama-2-7b-chat-hf",
messages=[{"role": "user", "content": "Tell me a story"}],
stream=True,
max_tokens=500
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
With API Key:
# Start server with API key
vllm serve model --api-key sk-secret-key
client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="sk-secret-key"
)
Without Authentication (Development Only):
client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="dummy" # Required by client but ignored by vLLM
)
import asyncio
from openai import AsyncOpenAI
client = AsyncOpenAI(base_url="http://localhost:8000/v1", api_key="dummy")
async def process_batch(prompts):
tasks = [
client.chat.completions.create(
model="meta-llama/Llama-2-7b-chat-hf",
messages=[{"role": "user", "content": p}],
max_tokens=100
)
for p in prompts
]
responses = await asyncio.gather(*tasks)
return [r.choices[0].message.content for r in responses]
# Usage
prompts = ["What is AI?", "Explain Python", "Define cloud computing"]
results = asyncio.run(process_batch(prompts))
from openai import OpenAI, APIError, RateLimitError
client = OpenAI(base_url="http://localhost:8000/v1", api_key="dummy")
try:
response = client.chat.completions.create(
model="meta-llama/Llama-2-7b-chat-hf",
messages=[{"role": "user", "content": "Hello"}]
)
except RateLimitError:
print("Rate limit exceeded. Retry after delay.")
except APIError as e:
print(f"API error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
messages = [
{"role": "system", "content": "You are a coding assistant."}
]
while True:
user_input = input("User: ")
if user_input.lower() == "exit":
break
messages.append({"role": "user", "content": user_input})
response = client.chat.completions.create(
model="meta-llama/Llama-2-7b-chat-hf",
messages=messages,
max_tokens=200
)
assistant_reply = response.choices[0].message.content
print(f"Assistant: {assistant_reply}")
messages.append({"role": "assistant", "content": assistant_reply})
Solution:
# Check if server is running
curl http://localhost:8000/health
# Verify correct port
vllm serve model --port 8000
# Client must use same port: base_url="http://localhost:8000/v1"
Solution:
# Verify model name matches exactly
curl http://localhost:8000/v1/models
# Use the exact model name shown
Solution:
Check request format. Common issues:
messages, model)# Correct format
{
"model": "model-name",
"messages": [{"role": "user", "content": "Hello"}]
}
Solution:
# Increase max_num_seqs for better throughput
vllm serve model --max_num_seqs 256
# Enable chunked prefill (v0.5.0+)
vllm serve model --enable-chunked-prefill