Skip to main content

👥 基于团队的路线选择

路由

根据团队ID将通话路由到不同的模型组

配置模型组

创建一个包含2个模型组和连接的Postgres数据库的config.yaml文件

model_list: 
- model_name: gpt-3.5-turbo-eu # 👈 模型组1
litellm_params:
model: azure/chatgpt-v-2
api_base: os.environ/AZURE_API_BASE_EU
api_key: os.environ/AZURE_API_KEY_EU
api_version: "2023-07-01-preview"
- model_name: gpt-3.5-turbo-worldwide # 👈 模型组2
litellm_params:
model: azure/chatgpt-v-2
api_base: os.environ/AZURE_API_BASE
api_key: os.environ/AZURE_API_KEY
api_version: "2023-07-01-preview"

general_settings:
master_key: sk-1234
database_url: "postgresql://..." # 👈 连接代理到数据库

启动代理

litellm --config /path/to/config.yaml

创建带有模型别名的团队

curl --location 'http://0.0.0.0:4000/team/new' \
--header 'Authorization: Bearer sk-1234' \ # 👈 主密钥
--header 'Content-Type: application/json' \
--data '{
"team_alias": "my-new-team_4",
"model_aliases": {"gpt-3.5-turbo": "gpt-3.5-turbo-eu"}
}'

# 返回 team_id: my-team-id

创建团队密钥

curl --location 'http://localhost:4000/key/generate' \
--header 'Authorization: Bearer sk-1234' \
--header 'Content-Type: application/json' \
--data '{
"team_id": "my-team-id", # 👈 你的团队ID
}'

用别名调用模型

curl --location 'http://0.0.0.0:4000/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer sk-A1L0C3Px2LJl53sF_kTF9A' \
--data '{
"model": "gpt-3.5-turbo", # 👈 模型
"messages": [{"role": "system", "content": "你是一个写诗专家"}, {"role": "user", "content": "给我写首诗"}, {"role": "user", "content": "你叫什么名字?"}],
"user": "usha"
}'
优云智算