AI21

AI21

LiteLLM은 다음과 같은 AI21 모델을 지원해요.

  • jamba-1.5-mini
  • jamba-1.5-large
  • j2-light
  • j2-mid
  • j2-ultra

팁: 모든 AI21 모델을 지원해요. litellm 요청을 보낼 때 model=ai21/<any-model-on-ai21>처럼 ai21/ 접두사를 붙이면 됩니다. 지원되는 전체 AI21 모델 목록은 여기에서 볼 수 있어요.

출처: 문서

본문

API 키 (API Keys)

import os
os.environ["AI21_API_KEY"] = "your-api-key"

LiteLLM Python SDK 사용법

샘플 사용법

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)

LiteLLM 프록시 서버 사용법

LiteLLM Proxy Server로 ai21 모델을 호출하는 방법이에요.

  1. 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
  1. 프록시를 시작해요.
$ litellm --config /path/to/config.yaml

지원되는 AI21 파라미터

param type AI21 등가물
documents Optional[List[Dict]] documents

AI21 고유 파라미터 전달 - documents

LiteLLM은 모든 AI21 고유 파라미터를 litellm.completion 함수에 전달할 수 있게 해 줘요. documents 파라미터를 전달하는 예시예요.

LiteLLM Python SDK

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",
                ...

AI21 모델

모델 이름 함수 호출 필수 OS 변수
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-mid completion('j2-mid', messages) os.environ['AI21_API_KEY']
j2-ultra completion('j2-ultra', messages) os.environ['AI21_API_KEY']

더 알아보기 (Learn more)