Clarifai
Clarifai
Anthropic, OpenAI, Qwen, xAI, Gemini 그리고 대부분의 오픈소스 LLM이 Clarifai에서 지원돼요.
출처: 문서
본문
개요 (Overview)
| 속성 | 설명 |
|---|---|
| 설명 | 통합 API로 다양한 LLM에 접근을 제공하는 AI 플랫폼. LiteLLM이 OpenAI 호환 인터페이스로 Clarifai 모델을 호출 |
| 공급자 문서 | Clarifai |
| OpenAI 호환 엔드포인트 | https://api.clarifai.com/v2/ext/openai/v1 |
| 지원 엔드포인트 | /chat/completions |
선행 조건
uv add litellm
필수 환경 변수
os.environ["CLARIFAI_PAT"] = "CLARIFAI_API_KEY" # CLARIFAI_PAT
Clarifai Personal access token은 이 링크를 참고해 얻을 수 있어요.
사용법 (Usage)
import os
from litellm import completion
os.environ["CLARIFAI_API_KEY"] = ""
response = completion(
model="clarifai/openai.chat-completion.gpt-oss-20b",
messages=[{ "content": "Tell me a joke about physics?","role": "user"}]
)
스트리밍 지원 (Streaming)
LiteLLM은 Clarifai 모델로 스트리밍 응답을 지원해요.
import litellm
for chunk in litellm.completion(
model="clarifai/openai.chat-completion.gpt-oss-20b",
api_key="CLARIFAI_API_KEY",
messages=[
{"role": "user", "content": "Tell me a fun fact about space."}
],
stream=True,
):
print(chunk.choices[0].delta)
Tool Calling (Function Calling)
LiteLLM으로 접근하는 Clarifai 모델은 함수 호출을 지원해요.
import litellm
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current temperature for a given location.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City and country e.g. Tokyo, Japan"
}
},
"required": ["location"],
"additionalProperties": False
},
}
}]
response = litellm.completion(
model="clarifai/openai.chat-completion.gpt-oss-20b",
api_key="CLARIFAI_API_KEY",
messages=[{"role": "user", "content": "What is the weather in Paris today?"}],
tools=tools,
)
print(response.choices[0].message.tool_calls)
Clarifai 모델
LiteLLM은 Clarifai 커뮤니티의 모든 모델을 지원해요.
🧠 OpenAI 모델
gpt-oss-20b, gpt-oss-120b, gpt-5-nano, gpt-5-mini, gpt-5, gpt-4o, o3 ... 외 다수
🤖 Anthropic 모델
claude-sonnet-4, claude-opus-4, claude-3_5-haiku, claude-3_7-sonnet ... 외 다수
🪄 xAI 모델
grok-3, grok-2-vision-1212, grok-2-1212, grok-code-fast-1, grok-2-image-1212 ... 외 다수
🔷 Google Gemini 모델
gemini-2_5-pro, gemini-2_5-flash-lite, gemini-2_0-flash, gemini-2_0-flash-lite ... 외 다수
🧩 Qwen 모델
Qwen3-30B-A3B-Instruct-2507, Qwen3-30B-A3B-Thinking-2507, Qwen3-14B, QwQ-32B-AWQ, Qwen2_5-VL-7B-Instruct, Qwen3-Coder-30B-A3B-Instruct ... 외 다수
💡 MiniCPM (OpenBMB) 모델
MiniCPM-o-2_6-language, MiniCPM3-4B, MiniCPM4-8B ... 외 다수
🧬 Microsoft Phi 모델
Phi-4-reasoning-plus, phi-4 ... 외 다수
🦙 Meta Llama 모델
Llama-3_2-3B-Instruct ... 외 다수
🔍 DeepSeek 모델
DeepSeek-R1-0528-Qwen3-8B ... 외 다수
LiteLLM Proxy 사용법
1. 환경에 키 저장
export CLARIFAI_PAT="CLARIFAI_API_KEY"
2. Proxy 시작
model_list:
- model_name: clarifai-model
litellm_params:
model: clarifai/openai.chat-completion.gpt-oss-20b
api_key: os.environ/CLARIFAI_PAT
litellm --config /path/to/config.yaml
# Server running on http://0.0.0.0:4000
3. 테스트
curl:
curl --location 'http://0.0.0.0:4000/chat/completions' \
--header 'Content-Type: application/json' \
--data ' {
"model": "clarifai-model",
"messages": [
{
"role": "user",
"content": "what llm are you"
}
]
}'
OpenAI v1.0.0+:
import openai
client = openai.OpenAI(
api_key="anything",
base_url="http://0.0.0.0:4000"
)
response = client.chat.completions.create(
model="clarifai-model",
messages = [
{
"role": "user",
"content": "this is a test request, write a short poem"
}
]
)
print(response)
중요 참고 사항
- Clarifai 모델 ID는 모델 이름 지정 시 항상
clarifai/접두사로 시작 - API 키로 Clarifai Personal Access Token(PAT) 사용
- 사용량은 Clarifai를 통해 추적되고 청구됨
- API rate limits는 Clarifai 계정 설정에 따름
- 대부분의 OpenAI 파라미터가 지원되지만 일부 고급 기능은 모델에 따라 다를 수 있음
FAQ
| 질문 | 답변 |
|---|---|
| 모든 Clarifai 모델을 LiteLLM과 사용할 수 있나요? | 대부분의 chat-completion 모델이 지원돼요. Clarifai 모델 URL을 모델로 사용하세요 |
| 별도 Clarifai PAT가 필요한가요? | 네, 유효한 Clarifai Personal Access Token이 필요해요 |
| Tool calling이 지원되나요? | 네, 기반이 되는 Clarifai 모델이 function/tool calling을 지원하면 가능해요 |
| 청구는 어떻게 처리되나요? | Clarifai 사용량은 Clarifai를 통해 별도로 청구돼요 |