Oauth 2.0 认证
如果你想使用 Oauth 2.0 令牌向 LiteLLM 代理发出 /chat 和 /embeddings 请求,请使用此功能。
info
这是一个企业级功能 - 如果你想免费试用以测试此功能是否符合你的需求,请与我们联系
使用方法
- 设置环境变量:
export OAUTH_TOKEN_INFO_ENDPOINT="https://your-provider.com/token/info"
export OAUTH_USER_ID_FIELD_NAME="sub"
export OAUTH_USER_ROLE_FIELD_NAME="role"
export OAUTH_USER_TEAM_ID_FIELD_NAME="team_id"
OAUTH_TOKEN_INFO_ENDPOINT: 验证 OAuth 令牌的 URLOAUTH_USER_ID_FIELD_NAME: 令牌信息响应中包含用户ID的字段OAUTH_USER_ROLE_FIELD_NAME: 令牌信息中包含用户角色的字段OAUTH_USER_TEAM_ID_FIELD_NAME: 令牌信息中包含用户团队ID的字段
- 在 litellm config.yaml 中启用
在你的 config.yaml 中设置此项
model_list:
- model_name: gpt-4
litellm_params:
model: openai/fake
api_key: fake-key
api_base: https://exampleopenaiendpoint-production.up.railway.app/
general_settings:
master_key: sk-1234
enable_oauth2_auth: true
- 在请求中使用令牌到 LiteLLM
curl --location 'http://0.0.0.0:4000/chat/completions' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "what llm are you"
}
]
}'