Skip to content

电话与语音 API

AI 驱动的外呼语音通话(Bland.ai)和钱包绑定电话号码(Twilio)。支持对话式 AI 通话并提供实时转写、购买/管理美国/加拿大专属号码、运营商/欺诈查询。仅支持外呼,不支持短信。

基础 URL:

  • 电话号码与查询:https://api.jarvisclaw.ai/v1/marketplace/phone
  • 语音通话:https://api.jarvisclaw.ai/v1/marketplace/voice

认证

两种方式均支持 — 所有请求通过 x402 链上结算:

方式Header描述
API KeyAuthorization: Bearer sk-...平台自动从你的 HD 钱包签名 x402
私钥 (x402)SDK 自动处理Agent 直接用自己的钱包签名 x402

详见 Agent 支付 (x402) 了解两种方式的完整工作原理。

定价

下表为参考价(按次,非按分钟)。精确扣费金额请读响应中的 price.amount

端点价格描述
POST /v1/marketplace/voice/call$0.54/次发起 AI 语音通话(最长 30 分钟)
POST /v1/marketplace/voice/call/transfer$0.54/次转接进行中的通话
POST /v1/marketplace/voice/call/end$0.001/次结束进行中的通话
GET /v1/marketplace/voice/call$0.542/次获取通话状态和转写文本
POST /v1/marketplace/phone/numbers/buy$5.002/号租赁电话号码(30 天)
POST /v1/marketplace/phone/numbers/renew$5.00/号续期 30 天
POST /v1/marketplace/phone/numbers/list$0.003/次列出你拥有的号码
POST /v1/marketplace/phone/numbers/release$0.003/次释放号码
POST /v1/marketplace/phone/lookup$0.01/次运营商信息查询
POST /v1/marketplace/phone/lookup/fraud$0.05/次欺诈风险 + SIM 卡替换检测
POST /v1/marketplace/phone/sms/send$0.05/条发送短信

所有 phone 端点都是 POST,且读取并不免费

numbers/listnumbers/releasePOST,各 $0.003 —— 上游对 GET 形式返回 "Unknown phone endpoint"。通过 GET .../voice/call 获取转写按 $0.542 计费,与发起通话同价(上游 如此收费),因此不要密集轮询。

通话按计费而非按分钟。

端点

方法服务端点描述
POSTphone/numbers/buy购买一个电话号码
POSTphone/numbers/list列出已拥有的号码
POSTvoice/call发起 AI 语音通话
GETvoice/call/:id获取通话转写和状态
POSTphone/lookup运营商信息查询
POSTphone/lookup/fraud欺诈风险检查

POST /numbers/buy

购买一个专属电话号码。号码按月租赁,30 天自动续费。

参数

参数类型必填描述
countrystring国家代码。默认:US。支持 US/CA
areaCodestring指定区号(如 415

响应

json
{
  "phone_number": "+14155551234",
  "country": "US",
  "area_code": "415",
  "status": "active",
  "lease_cost": 2.00,
  "expires_at": "2026-08-06T00:00:00Z",
  "auto_renew": true
}

POST /call

发起 AI 语音通话。AI 将按照指定任务描述与对方进行对话。

参数

参数类型必填描述
tostring目标号码(E.164 格式,如 +12025551234
fromstring来电号码(必须是你已租赁的号码)
taskstringAI 的对话任务描述
voicestring语音角色:mayamasonryanadriana
max_durationinteger最大通话时长(分钟)。默认:30,最大:30
first_sentencestringAI 的开场白

响应

json
{
  "call_id": "0721a3f8-9ae6-4b12-8f3a-1234567890ab",
  "status": "queued",
  "to": "+12025551234",
  "from": "+14155551234",
  "created_at": "2026-07-06T10:30:00Z"
}

GET /call/:id

获取通话状态和转写文本。通话进行中会返回实时状态,结束后返回完整转写。

响应

json
{
  "call_id": "0721a3f8-9ae6-...",
  "status": "completed",
  "to": "+12025551234",
  "from": "+14155551234",
  "call_length": 2.3,
  "answered_by": "human",
  "concatenated_transcript": "AI: Hi, I'm calling to confirm your dental appointment for Tuesday at 2 PM. Is that still good for you?\nHuman: Yes, that works.\nAI: Great, you're all set. Have a nice day!",
  "price": 0.161,
  "started_at": "2026-07-06T10:30:05Z",
  "ended_at": "2026-07-06T10:32:23Z"
}

POST /lookup

查询电话号码的运营商信息。

参数

参数类型必填描述
phoneNumberstringE.164 格式电话号码

响应

json
{
  "phone_number": "+14155551234",
  "country_code": "US",
  "national_format": "(415) 555-1234",
  "line_type_intelligence": {
    "carrier_name": "T-Mobile",
    "type": "mobile",
    "mobile_country_code": "310",
    "mobile_network_code": "260"
  }
}

POST /lookup/fraud

评估电话号码的欺诈风险。

参数

参数类型必填描述
phoneNumberstringE.164 格式电话号码

响应

json
{
  "phone_number": "+14155551234",
  "fraud_score": 15,
  "risk_level": "low",
  "flags": [],
  "is_voip": false,
  "is_prepaid": false
}

代码示例

bash
# 1. 购买号码
curl -X POST https://api.jarvisclaw.ai/v1/marketplace/phone/numbers/buy \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"country": "US", "areaCode": "415"}'

# 2. 发起 AI 通话(使用 voice 服务)
curl -X POST https://api.jarvisclaw.ai/v1/marketplace/voice/call \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+12025551234",
    "from": "+14155551234",
    "task": "确认周二下午2点的牙科预约,控制在60秒内。",
    "voice": "maya",
    "max_duration": 5
  }'

# 3. 获取通话转写($0.542/次)
curl https://api.jarvisclaw.ai/v1/marketplace/voice/call/0721a3f8-9ae6-... \
  -H "Authorization: Bearer sk-your-api-key"

# 运营商查询
curl -X POST https://api.jarvisclaw.ai/v1/marketplace/phone/lookup \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"phoneNumber": "+14155551234"}'

# 欺诈风险检查
curl -X POST https://api.jarvisclaw.ai/v1/marketplace/phone/lookup/fraud \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"phoneNumber": "+14155551234"}'
python
import requests

PHONE_BASE = "https://api.jarvisclaw.ai/v1/marketplace/phone"
VOICE_BASE = "https://api.jarvisclaw.ai/v1/marketplace/voice"
HEADERS = {
    "Authorization": "Bearer sk-your-api-key",
    "Content-Type": "application/json",
}

# 1. 购买号码
resp = requests.post(f"{PHONE_BASE}/numbers/buy", headers=HEADERS, json={
    "country": "US",
    "areaCode": "415",
})
number = resp.json()
print(f"已租赁: {number['phone_number']}, 到期: {number['expires_at']}")

# 2. 发起 AI 语音通话(独立服务: /marketplace/voice)
resp = requests.post(f"{VOICE_BASE}/call", headers=HEADERS, json={
    "to": "+12025551234",
    "from": number["phone_number"],
    "task": "确认周二下午2点的牙科预约。",
    "voice": "maya",
    "max_duration": 5,
})
call = resp.json()
print(f"通话已发起: {call['call_id']}")

# 3. 轮询转写($0.542/次)
resp = requests.get(f"{VOICE_BASE}/call/{call['call_id']}", headers=HEADERS)
result = resp.json()
print(f"状态: {result['status']}, 时长: {result.get('call_length')} 分钟")
print(f"接听方: {result.get('answered_by')}")
print(f"转写: {result.get('concatenated_transcript', '')[:200]}")
python
from jarvisclaw import MarketplaceClient

# x402 Agent 钱包 — 用 Base 上的 USDC 按次付费
client = MarketplaceClient(private_key="0x<evm-private-key>")

# 1. 购买号码
number = client.call("phone", "/numbers/buy", method="POST", json={
    "country": "US",
    "areaCode": "415",
})
print(f"已租赁: {number['phone_number']}")

# 2. 发起语音通话('voice' 服务)
call = client.call("voice", "/call", method="POST", json={
    "to": "+12025551234",
    "from": number["phone_number"],
    "task": "确认牙科预约。",
    "voice": "maya",
    "max_duration": 5,
})
print(f"通话已发起: {call['call_id']}")

# 3. 获取转写($0.542/次)
result = client.call("voice", f"/call/{call['call_id']}")
print(f"状态: {result['status']}")
go
package main

import (
    "context"
    "fmt"
    jc "github.com/api-jarvisclaw/go-sdk/v2"
)

func main() {
    ctx := context.Background()
    mc, _ := jc.NewMarketplaceClient(jc.WithAPIKey("sk-your-api-key"))

    // 1. 购买号码
    number, _ := mc.Post(ctx, "phone", "/numbers/buy", map[string]interface{}{
        "country":  "US",
        "areaCode": "415",
    })
    fmt.Printf("已租赁: %s\n", number["phone_number"])

    // 2. 语音通话('voice' 服务)
    call, _ := mc.Post(ctx, "voice", "/call", map[string]interface{}{
        "to":           "+12025551234",
        "from":         number["phone_number"],
        "task":         "确认牙科预约。",
        "voice":        "maya",
        "max_duration": 5,
    })
    fmt.Printf("通话已发起: %s\n", call["call_id"])

    // 3. 获取转写($0.542/次)
    transcript, _ := mc.Get(ctx, "voice", fmt.Sprintf("/call/%s", call["call_id"]))
    fmt.Printf("状态: %s, 接听方: %s\n", transcript["status"], transcript["answered_by"])
}
go
package main

import (
    "context"
    "fmt"
    jc "github.com/api-jarvisclaw/go-sdk/v2"
)

func main() {
    ctx := context.Background()
    mc, _ := jc.NewMarketplaceClient(jc.WithPrivateKey("0x<evm-private-key>"))

    // 1. 购买号码
    number, _ := mc.Post(ctx, "phone", "/numbers/buy", map[string]interface{}{
        "country":  "US",
        "areaCode": "415",
    })
    fmt.Printf("已租赁: %s\n", number["phone_number"])

    // 2. 语音通话
    call, _ := mc.Post(ctx, "voice", "/call", map[string]interface{}{
        "to":           "+12025551234",
        "from":         number["phone_number"],
        "task":         "确认牙科预约。",
        "voice":        "maya",
        "max_duration": 5,
    })
    fmt.Printf("通话已发起: %s\n", call["call_id"])

    // 3. 获取转写($0.542/次)
    transcript, _ := mc.Get(ctx, "voice", fmt.Sprintf("/call/%s", call["call_id"]))
    fmt.Printf("状态: %s\n", transcript["status"])
}

限制

  • 仅支持外呼 — 不支持接听来电
  • 无短信 — 电话号码仅限语音通话,不可收发短信
  • 最长通话 30 分钟 — 通话在 1800 秒时自动终止
  • 默认 US/CA — 美国和加拿大以外的号码需要 KYC 验证
  • 仅英语 — 语音 AI 目前仅支持英语对话
  • 30 天租期 — 电话号码按月自动续费,除非取消
  • E.164 格式必填 — 所有电话号码必须包含国家代码(如 +14155551234
  • 来电显示from 字段必须是你已租赁的号码,否则显示为未知号码