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)

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

相关推荐
智码看视界1 天前
开源大模型追踪:Qwen3-VL-30B-A3B :30B 总参单卡到底能不能跑?
多模态·视觉语言模型·本地部署·vllm·moe·开源大模型·qwen3-vl
小易老师AI实战1 天前
多模型融合实战:大模型+轻量小模型混合部署
vllm·大模型部署·模型路由·多模型融合·llm工程化·ai降本增效
chenxy021 天前
提高大模型推理性能的思路
vllm
吴佳浩 Alben2 天前
一文讲透推理引擎性能指标:TTFT、TPOT、KV命中率、并发,到底对应 vLLM / SGLang 的哪个参数?
人工智能·python·语言模型·架构·ai编程·vllm·sglang
Light Gao4 天前
从 LoRA 到 vLLM:大模型训练与企业部署名词通识(图解版)
vllm
数据与后端架构提升之路4 天前
四个模型,四条路:一份来自生产环境的 LLM 部署横评与选型框架
gpu算力·vllm·h100
缘友一世5 天前
GLM5.3 flash cybersec本地部署[5]:生产运维与故障恢复
ubuntu·vllm·glm5.3 flash
缘友一世6 天前
GLM5.3 flash cybersec本地部署[4]:基准测试与复现
vllm·glm5.3 flash
rjc_lihui7 天前
NCCL,Tokio ,vLLM ,Vue 3在线书籍
vllm