跳到主要内容

模型管理

添加新模型 + 获取模型信息,无需重启代理。

在 Config.yaml 中

model_list:
- model_name: text-davinci-003
litellm_params:
model: "text-completion-openai/text-davinci-003"
model_info:
metadata: "here's additional metadata on the model" # returned via GET /model/info

获取模型信息 - /model/info

检索 /model/info 端点中列出的每个模型的详细信息,包括来自 config.yaml 文件的描述,以及从您设置的 model_infolitellm 模型成本图中获取的额外模型信息(例如最大令牌数、每个输入令牌的成本等)。出于安全考虑,敏感细节(如 API 密钥)会被排除。

curl -X GET "http://0.0.0.0:4000/model/info" \
-H "accept: application/json" \

添加新模型

通过 /model/new API 向代理添加新模型,无需重启代理即可添加模型。

curl -X POST "http://0.0.0.0:4000/model/new" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-d '{ "model_name": "azure-gpt-turbo", "litellm_params": {"model": "azure/gpt-3.5-turbo", "api_key": "os.environ/AZURE_API_KEY", "api_base": "my-azure-api-base"} }'

模型参数结构

添加新模型时,您的 JSON 有效载荷应符合以下结构

  • model_name:新模型的名称(必需)。
  • litellm_params:一个字典,包含 LiteLLM 设置特定的参数(必需)。
  • model_info:一个可选字典,用于提供有关模型的附加信息。

以下是如何构建 ModelParams 的示例

{
"model_name": "my_awesome_model",
"litellm_params": {
"some_parameter": "some_value",
"another_parameter": "another_value"
},
"model_info": {
"author": "Your Name",
"version": "1.0",
"description": "A brief description of the model."
}
}

请记住,由于这两个端点都处于[测试版],您可能需要访问 API 说明中链接的相关 GitHub Issue,以检查更新或提供反馈

关于测试版端点的反馈非常宝贵,有助于改善所有用户的 API。

添加额外的模型信息

如果您想为模型添加显示名称、描述和标签,只需使用 model_info:

model_list:
- model_name: "gpt-4"
litellm_params:
model: "gpt-4"
api_key: "os.environ/OPENAI_API_KEY"
model_info: # 👈 KEY CHANGE
my_custom_key: "my_custom_value"

用法

  1. 向模型添加额外信息
model_list:
- model_name: "gpt-4"
litellm_params:
model: "gpt-4"
api_key: "os.environ/OPENAI_API_KEY"
model_info: # 👈 KEY CHANGE
my_custom_key: "my_custom_value"
  1. 调用 /model/info

使用具有模型 gpt-4 访问权限的密钥。

curl -L -X GET 'http://0.0.0.0:4000/v1/model/info' \
-H 'Authorization: Bearer LITELLM_KEY' \
  1. 预期响应

返回的 model_info = 您的自定义 model_info + (如果存在)LITELLM MODEL INFO

如何找到 LiteLLM 模型信息

告诉我们如何改进!

{
"data": [
{
"model_name": "gpt-4",
"litellm_params": {
"model": "gpt-4"
},
"model_info": {
"id": "e889baacd17f591cce4c63639275ba5e8dc60765d6c553e6ee5a504b19e50ddc",
"db_model": false,
"my_custom_key": "my_custom_value", # 👈 CUSTOM INFO
"key": "gpt-4", # 👈 KEY in LiteLLM MODEL INFO/COST MAP - https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json
"max_tokens": 4096,
"max_input_tokens": 8192,
"max_output_tokens": 4096,
"input_cost_per_token": 3e-05,
"input_cost_per_character": null,
"input_cost_per_token_above_128k_tokens": null,
"output_cost_per_token": 6e-05,
"output_cost_per_character": null,
"output_cost_per_token_above_128k_tokens": null,
"output_cost_per_character_above_128k_tokens": null,
"output_vector_size": null,
"litellm_provider": "openai",
"mode": "chat"
}
},
]
}