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)

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

相关推荐
GPUStack11 小时前
Day 0 实测|在 GPUStack 上部署 Inkling-BF16:8 卡 H20-141G 推理性能测试
ai·大模型·llm·gpu·vllm·gpu集群·sglang·gpustack
华科大胡子12 小时前
vLLM 与 SGLang 推理框架性能横评:架构、吞吐与延迟的深度较量
vllm
wen_zhufeng2 天前
vLLM-Omni TTS 推理加速实战手册
vllm
Yunzenn3 天前
强化学习1-Liu2026_GFlowRL_精读笔记
人工智能·笔记·深度学习·机器学习·transformer·集成学习·vllm
寒冰碧海4 天前
大模型部署从0到1(三):单机多卡 vLLM 部署Qwen3.6实战|Docker Compose 一键启动
docker·容器·vllm
执笔论英雄4 天前
【大模型推理 】 vllm kvconnet 学习
学习·vllm
古城小栈5 天前
vLLM 从入门到精通:企业级线上部署设置全讲解
vllm
Briwisdom6 天前
Speculative Decoding:用小模型给大模型“打草稿“,推理加速 2-3×
模型部署·vllm·eagle·llama.cpp·prefill·speculative·decoding
Briwisdom7 天前
LLM 推理引擎架构:vLLM / SGLang 的核心设计
架构·vllm·sglang·pagedattention·radixattention
陈 洪 伟7 天前
大模型推理引擎 vLLM(28):custom_all_reduce 单机/跨节点原理(IPC、Fabric、HSA)
fabric·vllm