컴퓨터 사용
컴퓨터 사용 (Computer Use)
컴퓨터 사용을 통해 모델이 스크린샷을 찍고 클릭, 타이핑, 스크롤 같은 동작을 수행하며 컴퓨터 인터페이스와 상호작용할 수 있어요. 이를 통해 AI 모델이 데스크톱 환경을 자율적으로 운영할 수 있습니다.
지원 프로바이더:
- Anthropic API (
anthropic/) - Bedrock (Anthropic) (
bedrock/) - Vertex AI (Anthropic) (
vertex_ai/)
지원 도구 타입:
computer- 표시 파라미터가 있는 컴퓨터 상호작용 도구bash- Bash 셸 도구text_editor- 텍스트 편집기 도구web_search- 웹 검색 도구
LiteLLM은 모든 지원 프로바이더에서 컴퓨터 사용 도구를 표준화합니다.
빠른 시작
- LiteLLM Python SDK
- LiteLLM Proxy Server
import os
from litellm import completion
os.environ["ANTHROPIC_API_KEY"] = "your-api-key"
# Computer use tool
tools = [
{
"type": "computer_20241022",
"name": "computer",
"display_height_px": 768,
"display_width_px": 1024,
"display_number": 0,
}
]
messages = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Take a screenshot and tell me what you see"
},
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=="
}
}
]
}
]
response = completion(
model="anthropic/claude-3-5-sonnet-latest",
messages=messages,
tools=tools,
)
print(response)
출처: 문서
본문
Proxy Server 사용
- config.yaml에 컴퓨터 사용 모델 정의
model_list:
- model_name: claude-3-5-sonnet-latest # Anthropic claude-3-5-sonnet-latest
litellm_params:
model: anthropic/claude-3-5-sonnet-latest
api_key: os.environ/ANTHROPIC_API_KEY
- model_name: claude-bedrock # Bedrock Anthropic model
litellm_params:
model: bedrock/us.anthropic.claude-3-5-sonnet-20241022-v2:0
aws_access_key_id: os.environ/AWS_ACCESS_KEY_ID
aws_secret_access_key: os.environ/AWS_SECRET_ACCESS_KEY
aws_region_name: us-west-2
model_info:
supports_computer_use: True # set supports_computer_use to True so /model/info returns this attribute as True
- proxy server 실행
litellm --config config.yaml
- OpenAI Python SDK로 테스트
import os
from openai import OpenAI
client = OpenAI(
api_key="sk-<your-litellm-api-key>", # your litellm proxy api key
base_url="http://0.0.0.0:4000"
)
response = client.chat.completions.create(
model="claude-3-5-sonnet-latest",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "Take a screenshot and tell me what you see"
},
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=="
}
}
]
}
],
tools=[
{
"type": "computer_20241022",
"name": "computer",
"display_height_px": 768,
"display_width_px": 1024,
"display_number": 0,
}
]
)
print(response)
모델이 컴퓨터 사용을 지원하는지 확인
- LiteLLM Python SDK
- LiteLLM Proxy Server
litellm.supports_computer_use(model="") -> 모델이 컴퓨터 사용을 지원하면 True, 아니면 False 반환
import litellm
assert litellm.supports_computer_use(model="anthropic/claude-sonnet-5") == True
assert litellm.supports_computer_use(model="anthropic/claude-opus-5") == True
assert litellm.supports_computer_use(model="bedrock/us.anthropic.claude-sonnet-5") == True
assert litellm.supports_computer_use(model="vertex_ai/claude-sonnet-5") == True
assert litellm.supports_computer_use(model="openai/gpt-5.6-terra") == False
- config.yaml에 컴퓨터 사용 모델 정의
model_list:
- model_name: claude-3-5-sonnet-latest # Anthropic claude-3-5-sonnet-latest
litellm_params:
model: anthropic/claude-3-5-sonnet-latest
api_key: os.environ/ANTHROPIC_API_KEY
- model_name: claude-bedrock # Bedrock Anthropic model
litellm_params:
model: bedrock/us.anthropic.claude-3-5-sonnet-20241022-v2:0
aws_access_key_id: os.environ/AWS_ACCESS_KEY_ID
aws_secret_access_key: os.environ/AWS_SECRET_ACCESS_KEY
aws_region_name: us-west-2
model_info:
supports_computer_use: True # set supports_computer_use to True so /model/info returns this attribute as True
- proxy server 실행
litellm --config config.yaml
/model_group/info호출로 모델이 컴퓨터 사용을 지원하는지 확인
curl -X 'GET' \
'http://localhost:4000/model_group/info' \
-H 'accept: application/json' \
-H "x-api-key: ***"
기대 응답:
{
"data": [
{
"model_group": "claude-3-5-sonnet-latest",
"providers": ["anthropic"],
"max_input_tokens": 200000,
"max_output_tokens": 8192,
"mode": "chat",
"supports_computer_use": true, # 👈 supports_computer_use is true
"supports_vision": true,
"supports_function_calling": true
},
{
"model_group": "claude-bedrock",
"providers": ["bedrock"],
"max_input_tokens": 200000,
"max_output_tokens": 8192,
"mode": "chat",
"supports_computer_use": true, # 👈 supports_computer_use is true
"supports_vision": true,
"supports_function_calling": true
}
]
}
다른 도구 타입
컴퓨터 사용은 다양한 상호작용 모드를 위해 여러 도구 타입을 지원합니다:
- 컴퓨터 도구
- Bash 도구
- 텍스트 편집기 도구
컴퓨터 도구 — computer_20241022 도구는 직접 화면 상호작용을 제공합니다.
import os
from litellm import completion
os.environ["ANTHROPIC_API_KEY"] = "your-api-key"
tools = [
{
"type": "computer_20241022",
"name": "computer",
"display_height_px": 768,
"display_width_px": 1024,
"display_number": 0,
}
]
messages = [
{
"role": "user",
"content": [
{"type": "text", "text": "Click on the search button in the screenshot"},
{"type": "image_url", "image_url": {"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=="}}
]
}
]
response = completion(
model="anthropic/claude-3-5-sonnet-latest",
messages=messages,
tools=tools,
)
print(response)
Bash 도구 — bash_20241022 도구는 명령줄 인터페이스 접근을 제공합니다.
import os
from litellm import completion
os.environ["ANTHROPIC_API_KEY"] = "your-api-key"
tools = [
{"type": "bash_20241022", "name": "bash"}
]
messages = [
{"role": "user", "content": "List the files in the current directory using bash"}
]
response = completion(
model="anthropic/claude-3-5-sonnet-latest",
messages=messages,
tools=tools,
)
print(response)
텍스트 편집기 도구 — text_editor_20250124 도구는 텍스트 파일 편집 기능을 제공합니다.
import os
from litellm import completion
os.environ["ANTHROPIC_API_KEY"] = "your-api-key"
tools = [
{"type": "text_editor_20250124", "name": "str_replace_editor"}
]
messages = [
{"role": "user", "content": "Create a simple Python hello world script"}
]
response = completion(
model="anthropic/claude-3-5-sonnet-latest",
messages=messages,
tools=tools,
)
print(response)
여러 도구와 함께하는 고급 사용법
단일 요청에서 서로 다른 컴퓨터 사용 도구를 결합할 수 있어요:
import os
from litellm import completion
os.environ["ANTHROPIC_API_KEY"] = "your-api-key"
tools = [
{
"type": "computer_20241022",
"name": "computer",
"display_height_px": 768,
"display_width_px": 1024,
"display_number": 0,
},
{
"type": "bash_20241022",
"name": "bash"
},
{
"type": "text_editor_20250124",
"name": "str_replace_editor"
}
]
messages = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Take a screenshot, then create a file describing what you see, and finally use bash to show the file contents"
},
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=="
}
}
]
}
response = completion(
model="anthropic/claude-3-5-sonnet-latest",
messages=messages,
tools=tools,
)
print(response)
스펙
컴퓨터 도구 (computer_20241022)
{
"type": "computer_20241022",
"name": "computer",
"display_height_px": 768, // Required: Screen height in pixels
"display_width_px": 1024, // Required: Screen width in pixels
"display_number": 0 // Optional: Display number (default: 0)
}
Bash 도구 (bash_20241022)
{
"type": "bash_20241022",
"name": "bash" // Required: Tool name
}
텍스트 편집기 도구 (text_editor_20250124)
{
"type": "text_editor_20250124",
"name": "str_replace_editor" // Required: Tool name
}
웹 검색 도구 (web_search_20250305)
{
"type": "web_search_20250305",
"name": "web_search" // Required: Tool name
}