AI21
LiteLLM unterstĂĽtzt die folgenden AI21 Modelle
jamba-1.5-minijamba-1.5-largej2-lightj2-midj2-ultra
Wir unterstützen ALLE AI21 Modelle, setzen Sie einfach model=ai21/<any-model-on-ai21> als Präfix, wenn Sie LiteLLM-Anfragen senden. Alle von LiteLLM unterstützten AI21-Modelle finden Sie hier
API SCHLÜSSEL​
import os
os.environ["AI21_API_KEY"] = "your-api-key"
LiteLLM Python SDK Verwendung​
Beispielverwendung​
from litellm import completion
# set env variable
os.environ["AI21_API_KEY"] = "your-api-key"
messages = [{"role": "user", "content": "Write me a poem about the blue sky"}]
completion(model="ai21/jamba-1.5-mini", messages=messages)
Nutzung des LiteLLM Proxy Servers​
Hier erfahren Sie, wie Sie ein AI21-Modell mit dem LiteLLM Proxy Server aufrufen können.
Konfigurieren Sie die config.yaml
model_list:
- model_name: my-model
litellm_params:
model: ai21/<your-model-name> # add ai21/ prefix to route as ai21 provider
api_key: api-key # api key to send your model
Starten Sie den Proxy
$ litellm --config /path/to/config.yamlAnfrage an LiteLLM Proxy Server senden
- OpenAI Python v1.0.0+
- curl
import openai
client = openai.OpenAI(
api_key="sk-1234", # pass litellm proxy key, if you're using virtual keys
base_url="http://0.0.0.0:4000" # litellm-proxy-base url
)
response = client.chat.completions.create(
model="my-model",
messages = [
{
"role": "user",
"content": "what llm are you"
}
],
)
print(response)curl --location 'http://0.0.0.0:4000/chat/completions' \
--header 'Authorization: Bearer sk-1234' \
--header 'Content-Type: application/json' \
--data '{
"model": "my-model",
"messages": [
{
"role": "user",
"content": "what llm are you"
}
],
}'
Unterstützte OpenAI-Parameter​
| Parameter | Typ | AI21 Äquivalent |
|---|---|---|
tools | Optional[Liste] | tools |
response_format | Optional[Dictionary] | response_format |
max_tokens | Optional[int] | max_tokens |
temperature | Optional[float] | temperature |
top_p | Optional[float] | top_p |
stop | Optional[Union[str, Liste]] | stop |
n | Optional[int] | n |
stream | Optional[bool] | stream |
seed | Optional[int] | seed |
tool_choice | Optional[str] | tool_choice |
Benutzer | Optional[str] | Benutzer |
Unterstützte AI21-Parameter​
| Parameter | Typ | AI21 Äquivalent |
|---|---|---|
Dokumente | Optional[List[Dict]] | Dokumente |
Übergeben von AI21-spezifischen Parametern - documents​
LiteLLM ermöglicht es Ihnen, alle AI21-spezifischen Parameter an die litellm.completion Funktion zu übergeben. Hier ist ein Beispiel, wie Sie den documents Parameter an die litellm.completion Funktion übergeben.
- LiteLLM Python SDK
- LiteLLM Proxy Server
response = await litellm.acompletion(
model="jamba-1.5-large",
messages=[{"role": "user", "content": "what does the document say"}],
documents = [
{
"content": "hello world",
"metadata": {
"source": "google",
"author": "ishaan"
}
}
]
)
import openai
client = openai.OpenAI(
api_key="sk-1234", # pass litellm proxy key, if you're using virtual keys
base_url="http://0.0.0.0:4000" # litellm-proxy-base url
)
response = client.chat.completions.create(
model="my-model",
messages = [
{
"role": "user",
"content": "what llm are you"
}
],
extra_body = {
"documents": [
{
"content": "hello world",
"metadata": {
"source": "google",
"author": "ishaan"
}
}
]
}
)
print(response)
Wir unterstützen ALLE AI21 Modelle, setzen Sie einfach model=ai21/<any-model-on-ai21> als Präfix, wenn Sie LiteLLM-Anfragen senden. Alle von LiteLLM unterstützten AI21-Modelle finden Sie hier
AI21 Modelle​
| Modellname | Funktionsaufruf | Erforderliche OS-Variablen |
|---|---|---|
| jamba-1.5-mini | completion('jamba-1.5-mini', messages) | os.environ['AI21_API_KEY'] |
| jamba-1.5-large | completion('jamba-1.5-large', messages) | os.environ['AI21_API_KEY'] |
| j2-light | completion('j2-light', messages) | os.environ['AI21_API_KEY'] |
| j2-mid | completion('j2-mid', messages) | os.environ['AI21_API_KEY'] |
| j2-ultra | completion('j2-ultra', messages) | os.environ['AI21_API_KEY'] |