
安装
uv tool install 'litellm[proxy]'
配置
编写配置文件:config.yaml
model_list:
- model_name: gpt-5
litellm_params:
model: openai/LongCat-2.0-Preview
api_base: https://api.longcat.chat/openai/
api_key: sk-xxx
- model_name: gpt-5-nano
litellm_params:
model: openai/qwen3.5:9b
api_base: http://localhost:11434/v1
api_key: none
运行
litellm --config config.yaml
测试
⚠️ 通过测试说明 LiteLLM 代理只支持中转,上游没有提供对应的API支持(LongCat 只支持 Chat Completions),LiteLLM 也不支持。
| 模型提供商 | 模型 | 接口类型 | 支持 |
|---|---|---|---|
| LongCat | gpt-5 | Chat Completions | ✅ |
| Responses | ❌ | ||
| Ollama | gpt-5-nano | Chat Completions | ✅ |
| Responses | ✅ |
测试 Chat Completions 接口
curl --location 'http://0.0.0.0:4000/v1/chat/completions' \
--header 'Content-Type: application/json' \
--data ' {
"model": "gpt-5",
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己。"
}
]
}
'
curl --location 'http://0.0.0.0:4000/v1/chat/completions' \
--header 'Content-Type: application/json' \
--data ' {
"model": "gpt-5-nano",
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己。"
}
]
}
'
测试 Responses 接口
curl --location 'http://0.0.0.0:4000/v1/responses' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-5",
"input": "你是AI助手。请根据用户输入的问题,提供简洁、准确的回答。如果你不确定答案,可以说“我不知道”。",
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己。"
}
]
}'
curl --location 'http://0.0.0.0:4000/v1/responses' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-5-nano",
"input": "你是AI助手。请根据用户输入的问题,提供简洁、准确的回答。如果你不确定答案,可以说“我不知道”。",
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己。"
}
]
}'
FAQ
优先使用 conda 环境中安装的旧版本 litellm,没有使用 uv 安装的最新版本。解决方法:
/opt/miniconda/bin/pip uninstall litellm -y
下面是完整的操作记录:
(base) ➜ litellm git:(main) ✗ uv tool upgrade litellm
Nothing to upgrade
(base) ➜ litellm git:(main) ✗ litellm -v
LiteLLM: Current Version = 1.48.1
(base) ➜ litellm git:(main) ✗ which litellm
/opt/miniconda/bin/litellm
(base) ➜ litellm git:(main) ✗ uv tool list
litellm v1.86.2
- litellm
- litellm-proxy
(base) ➜ litellm git:(main) ✗ /opt/miniconda/bin/litellm -v
LiteLLM: Current Version = 1.48.1
(base) ➜ litellm git:(main) ✗ conda uninstall litellm
Collecting package metadata (repodata.json): done
Solving environment: failed
PackagesNotFoundError: The following packages are missing from the target environment:
- litellm
(base) ➜ litellm git:(main) ✗ which litellm
/opt/miniconda/bin/litellm
(base) ➜ litellm git:(main) ✗ /opt/miniconda/bin/pip uninstall litellm -y
Found existing installation: litellm 1.48.1
Uninstalling litellm-1.48.1:
Successfully uninstalled litellm-1.48.1
(base) ➜ litellm git:(main) ✗ which litellm
/Users/junjian/.local/bin/litellm
(base) ➜ litellm git:(main) ✗ litellm -v
LiteLLM: Current Version = 1.86.2