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)

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

相关推荐
梦雨羊2 小时前
vllm单推理测试
vllm
大模型推理18 小时前
《Nano-vLLM 源码解读》第 16 篇 · Linear 投影
vllm
嘉陵妹妹1 天前
VLLM auto DL环境配置
vllm
an86950011 天前
【无标题】
vllm
蔡不菜和他的uU们2 天前
vLLM实践之个人AI基建——云端vLLM+SSH Tunnel+本地Cherry Studio
人工智能·ssh·vllm
likerhood3 天前
服务器使用 vLLM 部署 Qwen2.5-Coder-7B-CL 笔记
服务器·笔记·vllm
一只努力的微服务3 天前
vLLM vs SGLang 深度技术对比
vllm·sglang
做个文艺程序员4 天前
第08篇:K8s 部署 AI 大模型推理服务:GPU 调度 × vLLM × Java 客户端集成——从 0 到生产的完整方案
人工智能·kubernetes·vllm
reset20215 天前
vllm性能优化
性能优化·vllm
我叫张土豆5 天前
V100 显卡部署 Qwen3-ASR-1.7B 语音识别模型(vLLM + Docker 完整教程)
docker·语音识别·vllm