Nebius AI Studio

Nebius AI Studio

https://docs.nebius.com/studio/inference/quickstart

LiteLLM은 Nebius AI Studio의 모든 모델을 지원해요. 모델을 사용하려면 model=nebius/<any-model-on-nebius-ai-studio>처럼 litellm 요청에 nebius/를 접두어로 붙이면 돼요. 지원 모델의 전체 목록은 https://studio.nebius.ai/ 에서 확인할 수 있어요.

API 키 (API Key)

import os
# env variable
os.environ['NEBIUS_API_KEY']

샘플 사용법: 텍스트 생성 (Sample Usage: Text Generation)

from litellm import completion
import os

os.environ['NEBIUS_API_KEY'] = "insert-your-nebius-ai-studio-api-key"
response = completion(
    model="nebius/Qwen/Qwen3-235B-A22B",
    messages=[
        {
            "role": "user",
            "content": "What character was Wall-e in love with?",
        }
    ],
    max_tokens=10,
    response_format={ "type": "json_object" },
    seed=123,
    stop=["\n\n"],
    temperature=0.6,  # either set temperature or `top_p`
    top_p=0.01,  # to get as deterministic results as possible
    tool_choice="auto",
    tools=[],
    user="user",
)
print(response)

샘플 사용법 - 스트리밍 (Sample Usage - Streaming)

from litellm import completion
import os

os.environ['NEBIUS_API_KEY'] = ""
response = completion(
    model="nebius/Qwen/Qwen3-235B-A22B",
    messages=[
        {
            "role": "user",
            "content": "What character was Wall-e in love with?",
        }
    ],
    stream=True,
    max_tokens=10,
    response_format={ "type": "json_object" },
    seed=123,
    stop=["\n\n"],
    temperature=0.6,  # either set temperature or `top_p`
    top_p=0.01,  # to get as deterministic results as possible
    tool_choice="auto",
    tools=[],
    user="user",
)

for chunk in response:
    print(chunk)

샘플 사용법 - Embedding

from litellm import embedding
import os

os.environ['NEBIUS_API_KEY'] = ""
response = embedding(
    model="nebius/BAAI/bge-en-icl",
    input=["What character was Wall-e in love with?"],
)
print(response)

LiteLLM Proxy Server와 함께 사용하기 (Usage with LiteLLM Proxy Server)

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

  • config.yaml 수정:
model_list:
  - model_name: my-model
    litellm_params:
      model: nebius/<your-model-name>  # add nebius/ prefix to use Nebius AI Studio as provider
      api_key: api-key                 # api key to send your model
  • 프록시 시작:
$ litellm --config /path/to/config.yaml
  • LiteLLM Proxy Server에 요청 보내기:

  • OpenAI Python v1.0.0+

  • curl

import openai
client = openai.OpenAI(
    api_key="litellm-proxy-key",             # 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 character was Wall-e in love with?"
        }
    ],
)

print(response)
curl --location 'http://0.0.0.0:4000/chat/completions' \
    --header 'Authorization: ***' \
    --header 'Content-Type: application/json' \
    --data '{
    "model": "my-model",
    "messages": [
        {
        "role": "user",
        "content": "What character was Wall-e in love with?"
        }
    ],
}'

지원 파라미터 (Supported Parameters)

Nebius 제공자는 다음 파라미터를 지원해요.

Chat Completion 파라미터 (Chat Completion Parameters)

파라미터 타입 설명
frequency_penalty number 텍스트에서의 빈도에 따라 새 토큰에 패널티를 부여
function_call string/object 모델이 함수를 호출하는 방식을 제어
functions array 모델이 JSON 입력을 생성할 수 있는 함수 목록
logit_bias map 지정된 토큰의 가능성 수정
max_tokens integer 생성할 최대 토큰 수
n integer 생성할 completion 수
presence_penalty number 지금까지 나타난 토큰 여부에 따라 토큰에 패널티 부여
response_format object 응답 형식, 예: {"type": "json"}
seed integer 결정적 결과를 위한 샘플링 시드
stop string/array API가 토큰 생성을 중단할 시퀀스
stream boolean 응답을 스트리밍할지 여부
temperature number 무작위성 제어 (0-2)
top_p number 핵(nucleus) 샘플링 제어
tool_choice string/object 호출할 함수(있다면) 제어
tools array 모델이 사용할 수 있는 도구 목록
user string 사용자 식별자

Embedding 파라미터 (Embedding Parameters)

파라미터 타입 설명
input string/array 임베딩할 텍스트
user string 사용자 식별자

오류 처리 (Error Handling)

이 통합은 표준 LiteLLM 오류 처리를 사용해요. 일반적인 오류는 다음과 같아요:

  • 인증 오류 (Authentication Error): API 키 확인
  • 모델 없음 (Model Not Found): 유효한 모델명을 사용 중인지 확인
  • 속도 제한 오류 (Rate Limit Error): 속도 제한을 초과함
  • 타임아웃 오류 (Timeout Error): 요청이 너무 오래 걸림

출처: 문서

본문

더 알아보기 (Learn more)