OpenLLM 시작하기

OpenLLM 시작하기

OpenLLM은 BentoML 팀이 만든 오픈소스 LLM 서빙 플랫폼이에요. 오픈소스 LLM(Llama 3.3, Qwen2.5, Phi3 등)이나 커스텀 모델을 OpenAI 호환 API로 단일 명령으로 서빙할 수 있게 해줘요. 내장 채팅 UI, 최신 추론 백엔드, Docker·Kubernetes·BentoCloud로의 엔터프라이즈 배포 워크플로를 제공해요. "셀프호스팅 LLM을 쉽게" 만드는 게 목표예요.

설치와 실행

설치 후 인터랙티브하게 탐색할 수 있어요.

pip install openllm
openllm hello

출처: https://github.com/bentoml/OpenLLM/blob/main/README.md

LLM 서버 시작

로컬에 LLM 서버를 띄우려면 openllm serve 명령에 모델 버전을 지정해요.

openllm serve llama3.2:1b

OpenLLM은 모델 웨이트를 저장하지 않아요. 게이티드 모델은 Hugging Face 토큰(HF_TOKEN)이 필요해요. 토큰을 만들고 게이티드 모델에 액세스를 요청한 뒤, 환경 변수로 설정하면 돼요.

export HF_TOKEN=<your token>

서버는 http://localhost:3000에서 OpenAI 호환 API로 접근할 수 있어요.

OpenAI 클라이언트로 호출

OpenAI 호환 API라서 평소 쓰던 OpenAI 파이썬 클라이언트를 base_url만 바꿔 쓸 수 있어요.

from openai import OpenAI

client = OpenAI(base_url='http://localhost:3000/v1', api_key='na')

chat_completion = client.chat.completions.create(
    model="meta-llama/Llama-3.2-1B-Instruct",
    messages=[
        {"role": "user", "content": "Explain superconductors like I'm five years old"}
    ],
    stream=True,
)
for chunk in chat_completion:
    print(chunk.choices[0].delta.content or "", end="")

모델 이름은 도구·방식에 따라 다를 수 있고, API 키는 클라이언트 인증용으로 선택 사항이에요.

채팅 UI와 CLI

서버가 뜨면 http://localhost:3000/chat에서 채팅 UI를 쓸 수 있어요. CLI에서 대화를 시작하려면 openllm run을 써요.

openllm run llama3:8b

더 알아보기