The official Python library for the ClawOps Voice API
Project description
ClawOps Python SDK
ClawOps Voice API의 공식 Python 라이브러리입니다.
설치
# REST API SDK만 사용
pip install clawops
# AI Agent 포함
pip install clawops[agent]
# 특정 프로바이더 포함
pip install clawops[agent,openai-llm,deepgram,elevenlabs,mcp]
# 전체 설치
pip install clawops[agent-all]
AI Agent (음성 에이전트)
ClawOpsAgent를 사용하면 한 줄로 인바운드 전화를 AI로 처리할 수 있습니다. ngrok 없이 WebSocket 역방향 연결로 동작합니다.
from clawops.agent import ClawOpsAgent
agent = ClawOpsAgent(
from_="07012341234", # 수신 번호
system_prompt="친절한 상담원입니다. 고객의 질문에 답변해주세요.",
voice="marin", # OpenAI 음성
language="ko",
)
@agent.tool
async def check_order(order_id: str) -> str:
"""주문 상태를 확인합니다."""
return "배송 완료"
@agent.on("call_start")
async def on_start(call):
print(f"통화 시작: {call.from_number} -> {call.to_number}")
agent.listen() # WebSocket 연결 후 인바운드 대기
자세한 사용법은 Agent 문서 를 참고하세요. (Tool, 이벤트, 통화 녹음, 파이프라인 모드, MCP 연동 등)
REST API 사용법
from clawops import ClawOps
client = ClawOps(
api_key="sk_...", # 또는 CLAWOPS_API_KEY 환경변수 사용
account_id="AC1a2b3c4d", # 또는 CLAWOPS_ACCOUNT_ID 환경변수 사용
)
통화 (Calls)
# 발신 전화 생성
call = client.calls.create(
to="01012345678",
from_="07052358010",
url="https://my-app.com/twiml",
status_callback="https://my-app.com/status",
status_callback_event="initiated ringing answered completed",
)
print(call.call_id)
# 통화 목록 조회 (페이지네이션)
page = client.calls.list(status="completed", page=0, page_size=20)
for call in page:
print(call.call_id, call.status)
# 모든 통화를 자동으로 순회
for call in client.calls.list().auto_paging_iter():
print(call.call_id)
# 특정 통화 조회
call = client.calls.get("CAabcdef1234567890")
# 통화 종료
call = client.calls.update("CAabcdef1234567890", status="completed")
전화번호 (Numbers)
# 번호 구매
number = client.numbers.create(source="pool")
print(number.phone_number)
# 번호 목록 조회
numbers = client.numbers.list()
# 웹훅 URL 변경
number = client.numbers.update("07012340001", webhook_url="https://my-app.com/webhook")
# 번호 해제
client.numbers.delete("07012340001")
SIP 자격증명 (SIP Credentials)
# SIP 자격증명 생성
cred = client.sip.credentials.create(display_name="Office Phone")
print(cred.credential_id, cred.sip_username)
# 자격증명 목록 조회
creds = client.sip.credentials.list()
# 특정 자격증명 조회
cred = client.sip.credentials.get("clu1abc2def3ghi")
# 자격증명 삭제
client.sip.credentials.delete("clu1abc2def3ghi")
멀티 계정 접근
# 다른 계정의 리소스에 접근
other = client.accounts("AC_other_account_id")
other.calls.list()
other.numbers.list()
비동기 사용법
from clawops import AsyncClawOps
# async context manager 사용
async with AsyncClawOps(api_key="sk_...", account_id="AC1a2b3c4d") as client:
call = await client.calls.create(
to="01012345678",
from_="07052358010",
url="https://my-app.com/twiml",
)
print(call.call_id)
# 모든 리소스 메서드는 비동기 버전을 제공합니다
page = await client.calls.list(status="completed")
async for call in page.auto_paging_iter():
print(call.call_id)
웹훅 서명 검증
client.webhooks.verify(
url="https://my-app.com/webhook",
params={"CallId": "CA...", "CallStatus": "completed"},
signature=request.headers["X-Signature"],
signing_key="your_account_signing_key",
)
서명이 유효하지 않으면 WebhookVerificationError가 발생합니다.
에러 처리
from clawops import ClawOps, BadRequestError, AuthenticationError, NotFoundError
client = ClawOps()
try:
call = client.calls.create(to="01012345678", from_="07052358010", url="https://...")
except BadRequestError as e:
print(f"잘못된 요청: {e.status_code} - {e.body}")
except AuthenticationError as e:
print(f"유효하지 않은 API 키: {e.status_code}")
except NotFoundError as e:
print(f"리소스를 찾을 수 없음: {e.status_code}")
모든 에러는 ClawOpsError를 상속합니다. HTTP 에러는 status_code, response, body, request 속성을 제공합니다.
| 에러 | 상태 코드 |
|---|---|
BadRequestError |
400 |
AuthenticationError |
401 |
PermissionDeniedError |
403 |
NotFoundError |
404 |
ConflictError |
409 |
UnprocessableEntityError |
422 |
InternalServerError |
500+ |
ServiceUnavailableError |
503 |
설정
재시도
기본적으로 408, 409, 429, 500+ 에러 시 지수 백오프로 최대 2회 재시도합니다.
client = ClawOps(max_retries=5)
# 재시도 비활성화
client = ClawOps(max_retries=0)
타임아웃
기본 타임아웃은 600초 (연결 타임아웃 5초)입니다. 클라이언트 또는 요청 단위로 변경할 수 있습니다:
# 클라이언트 단위
client = ClawOps(timeout=30.0)
# 요청 단위
call = client.calls.create(..., timeout=10.0)
커스텀 HTTP 클라이언트
프록시, 커스텀 인증서 등 고급 설정이 필요한 경우 httpx.Client를 직접 주입할 수 있습니다:
import httpx
client = ClawOps(
http_client=httpx.Client(proxies="http://proxy.example.com:8080"),
)
환경변수
| 변수 | 설명 | 필수 여부 |
|---|---|---|
CLAWOPS_API_KEY |
API 키 (sk_...) |
예 (생성자에 전달하지 않은 경우) |
CLAWOPS_ACCOUNT_ID |
기본 계정 ID (AC...) |
예 (생성자에 전달하지 않은 경우) |
CLAWOPS_BASE_URL |
API 기본 URL | 아니오 (기본값: https://api.claw-ops.com) |
OPENAI_API_KEY |
OpenAI API 키 | Agent 사용 시 (생성자에 전달하지 않은 경우) |
문서
- AI Agent 가이드 — 음성 에이전트 상세 사용법, 파이프라인 모드, MCP 연동
요구사항
- Python 3.9+
httpx>= 0.23.0pydantic>= 2.0.0aiohttp>= 3.9.0 (Agent 사용 시)
라이선스
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clawops-0.2.3.tar.gz.
File metadata
- Download URL: clawops-0.2.3.tar.gz
- Upload date:
- Size: 44.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42f469b337272fdbd2c99eccc94da3bd33d396524328d125dc10caee153a38ee
|
|
| MD5 |
f20ac6476594e8646e0a8500f486e612
|
|
| BLAKE2b-256 |
eef8979ab371b0419d61aa639223d4af1f2eac816ae3f7edb9a54fc09b9b6f48
|
Provenance
The following attestation bundles were made for clawops-0.2.3.tar.gz:
Publisher:
publish.yml on learners-superpumped/clawops-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clawops-0.2.3.tar.gz -
Subject digest:
42f469b337272fdbd2c99eccc94da3bd33d396524328d125dc10caee153a38ee - Sigstore transparency entry: 1049723397
- Sigstore integration time:
-
Permalink:
learners-superpumped/clawops-python@47b5d50b3f56c6f3f98ab1f63c6793fcb520b764 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/learners-superpumped
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@47b5d50b3f56c6f3f98ab1f63c6793fcb520b764 -
Trigger Event:
push
-
Statement type:
File details
Details for the file clawops-0.2.3-py3-none-any.whl.
File metadata
- Download URL: clawops-0.2.3-py3-none-any.whl
- Upload date:
- Size: 44.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64b192395e976356503e474751376490893e622dffe69ff47a9735868a5d9e9c
|
|
| MD5 |
27c5d7489eb9fae11751644c611702d6
|
|
| BLAKE2b-256 |
41cbc47879bf3a249d7c5d741c457ea12065763cc2d78dd146330b6dbf705909
|
Provenance
The following attestation bundles were made for clawops-0.2.3-py3-none-any.whl:
Publisher:
publish.yml on learners-superpumped/clawops-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clawops-0.2.3-py3-none-any.whl -
Subject digest:
64b192395e976356503e474751376490893e622dffe69ff47a9735868a5d9e9c - Sigstore transparency entry: 1049723398
- Sigstore integration time:
-
Permalink:
learners-superpumped/clawops-python@47b5d50b3f56c6f3f98ab1f63c6793fcb520b764 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/learners-superpumped
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@47b5d50b3f56c6f3f98ab1f63c6793fcb520b764 -
Trigger Event:
push
-
Statement type: