mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
(docs) using litellm router
This commit is contained in:
parent
824b8b1b62
commit
e46980c56c
1 changed files with 25 additions and 1 deletions
|
|
@ -50,14 +50,38 @@ model_list = [{ # list of model deployments
|
|||
"model": "gpt-3.5-turbo",
|
||||
"api_key": os.getenv("OPENAI_API_KEY"),
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
"model_name": "gpt-4",
|
||||
"litellm_params": { # params for litellm completion/embedding call
|
||||
"model": "azure/gpt-4",
|
||||
"api_key": os.getenv("AZURE_API_KEY"),
|
||||
"api_base": os.getenv("AZURE_API_BASE"),
|
||||
"api_version": os.getenv("AZURE_API_VERSION"),
|
||||
}
|
||||
}, {
|
||||
"model_name": "gpt-4",
|
||||
"litellm_params": { # params for litellm completion/embedding call
|
||||
"model": "gpt-4",
|
||||
"api_key": os.getenv("OPENAI_API_KEY"),
|
||||
}
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
router = Router(model_list=model_list)
|
||||
|
||||
# openai.ChatCompletion.create replacement
|
||||
# requests with model="gpt-3.5-turbo" will pick a deployment where model_name="gpt-3.5-turbo"
|
||||
response = await router.acompletion(model="gpt-3.5-turbo",
|
||||
messages=[{"role": "user", "content": "Hey, how's it going?"}])
|
||||
|
||||
print(response)
|
||||
|
||||
# openai.ChatCompletion.create replacement
|
||||
# requests with model="gpt-4" will pick a deployment where model_name="gpt-4"
|
||||
response = await router.acompletion(model="gpt-4",
|
||||
messages=[{"role": "user", "content": "Hey, how's it going?"}])
|
||||
|
||||
print(response)
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue