LiteLLM + vLLM模型调用引擎架构

二、Docker 安装 vLLM

docker-compose.yml

复制代码
version: '3.7'

services:

  vllm-qwen:
    image: vllm/vllm-openai:latest
    container_name: vllm-qwen
    runtime: nvidia
    environment:
      - NVIDIA_VISIBLE_DEVICES=all
    volumes:
      - ./models:/models
    command: >
      --model /models/qwen/Qwen2.5-0.5B-Instruct
      --host 0.0.0.0
      --port 8000
      --gpu-memory-utilization 0.5
      --max-model-len 1024
    ports:
      - "8000:8000"

  litellm:
    image: ghcr.io/berriai/litellm:main-latest
    container_name: litellm
    volumes:
      - ./config.yaml:/app/config.yaml
    command: --config /app/config.yaml
    ports:
      - "4000:4000"
    depends_on:
      - vllm-qwen

把模型放到models

LiteLLM 配置config.yaml

复制代码
model_list:
  - model_name: qwen
    litellm_params:
      model: openai//models/qwen/Qwen2.5-0.5B-Instruct  # 使用 vLLM 返回的完整模型 ID
      api_base: http://vllm-qwen:8000/v1
      api_key: none

启动服务

docker compose up -d

此过程比较慢,因为下载的比较大。

测试 vLLM

curl http://localhost:8000/v1/models

测试 LiteLLM

curl http://localhost:4000/v1/models

整体测试:

curl http://localhost:4000/v1/chat/completions -H "Content-Type: application/json" -d "{\"model\":\"qwen\",\"messages\":[{\"role\":\"user\",\"content\":\"你好\"}]}"

python代码测试:

复制代码
from openai import OpenAI

client = OpenAI(
    api_key="anything",
    base_url="http://10.61.104.181:4000/v1"
)

response = client.chat.completions.create(
    model="qwen",
    messages=[
        {"role": "user", "content": "你好,讲个笑话"}
    ]
)
 
print(response.choices[0].message.content)

增加多个模型(暂未尝试)

相关推荐
大模型推理3 天前
Nano-vLLM 源码解读 - 7. Continuous Batching
深度学习·自然语言处理·vllm
周公3 天前
记一次在双 RTX 3090 工作站上部署 vLLM 与 Qwen3.6-35B-AWQ 的实战记录
python·ai·llama·vllm·ollama
清风lsq4 天前
大模型-vllm 投机解码实现
人工智能·vllm·大模型推理
清风lsq4 天前
大模型-vllm 实现lora解析
人工智能·vllm·大模型推理
我叫Double7 天前
本地服务器部署vllm+Qwen3-Coder-Next的模型
vllm
m0_564876847 天前
vllm的pageattention到底是怎么回事?
vllm
AI视觉网奇7 天前
docker vllm 开机启动
docker·容器·vllm
做个文艺程序员10 天前
vLLM 部署大模型推理服务完全教程:吞吐量是 Ollama 的 10 倍,生产环境首选
vllm·vllm教程
liuyunshengsir10 天前
LMCache + vLLM 部署指南(以 Qwen3-0.6B 为例)
vllm
诸葛老刘11 天前
在PC机上 使用docker vLLM镜像部署Qwen3-1.7B
docker·vllm