🔌 麻邻国 AI API

全球首个商用级棋牌AI推理API — 覆盖9种主流玩法,毫秒级响应

快速开始

1. 获取 API Key

注册麻邻国会员后,在控制台获取你的 API Key。免费额度:100次/天

2. 发送第一个请求

Python
cURL
JavaScript
import requests

API_KEY = "your_api_key_here"
BASE_URL = "https://api.malinguo.com/v1"

resp = requests.post(f"{BASE_URL}/predict", json={
    "game": "sichuan",
    "hand": ["1m","2m","3m","4p","5p","6p","7s","8s","9s","1z","1z","2z","3z"],
    "discards": [],
    "dora": ["5m"],
    "seat_wind": "E",
    "round_wind": "E"
}, headers={"Authorization": f"Bearer {API_KEY}"})

data = resp.json()
print(f"推荐打: {data['best_tile']}")
print(f"置信度: {data['confidence']:.1%}")
print(f"胜率:   {data['win_rate']:.1%}")
curl -X POST https://api.malinguo.com/v1/predict \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "game": "sichuan",
    "hand": ["1m","2m","3m","4p","5p","6p","7s","8s","9s","1z","1z","2z","3z"],
    "discards": [],
    "dora": ["5m"],
    "seat_wind": "E",
    "round_wind": "E"
  }'
const resp = await fetch("https://api.malinguo.com/v1/predict", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    game: "sichuan",
    hand: ["1m","2m","3m","4p","5p","6p","7s","8s","9s","1z","1z","2z","3z"],
    discards: [],
    dora: ["5m"],
    seat_wind: "E",
    round_wind: "E"
  })
});

const data = await resp.json();
console.log(`推荐打: ${data.best_tile}, 置信度: ${data.confidence}`);

3. 响应示例

{
  "best_tile": "3z",
  "confidence": 0.87,
  "win_rate": 0.42,
  "alternatives": [
    {"tile": "2z", "probability": 0.09},
    {"tile": "1z", "probability": 0.03}
  ],
  "explanation": "3z是孤立字牌,与手牌无搭子关系。手牌主力为万子和筒子,优先清理字牌。",
  "tags": ["孤张", "效率"],
  "shanten": 1,
  "latency_ms": 12
}

API 参考

POST /v1/predict

根据当前手牌状态,返回AI推荐的最佳出牌。

参数类型必填说明
gamestring玩法:sichuan changsha guangdong hongzhong riichi taiwan doudizhu guandan texas
handstring[]手牌数组,如 ["1m","2m","3m"]
discardsstring[]已出的牌(用于推断安全牌)
dorastring[]宝牌指示器(日麻/台湾麻将)
seat_windstring自风:E/S/W/N
round_windstring场风
meldsobject[]已副露的面子
missing_suitstring四川麻将定缺花色:m/p/s

POST /v1/evaluate

评估指定模型在给定对手下的胜率。

参数类型必填说明
gamestring玩法类型
modelstring模型版本(默认latest)
opponentstringrandom/greedy(默认random)
episodesint评估局数(默认100,最大500)

GET /v1/models

返回所有可用模型及其最新胜率指标。

{
  "models": [
    {
      "game": "changsha",
      "version": "evo-gen3",
      "vs_random": 0.43,
      "vs_greedy": 0.20,
      "updated_at": "2026-03-16"
    },
    ...
  ]
}

POST /v1/explain

对指定出牌生成策略解释文本(中文)。

参数类型必填说明
gamestring玩法类型
handstring[]手牌
tilestring要解释的出牌
confidencefloat置信度(0-1)
win_ratefloat当前胜率(0-1)

牌面编码

麻将

花色编码示例
万子1m ~ 9m一万=1m, 九万=9m
筒子1p ~ 9p一筒=1p
条子1s ~ 9s一条=1s
风牌E S W N东=E
三元牌Z F B中=Z, 发=F, 白=B

扑克

编码示例
{rank}{suit}Ah=黑桃A, Kd=方块K, Tc=梅花10
花色: h=红心 d=方块 c=梅花 s=黑桃
大小王: JK jk掼蛋/斗地主用

错误码

HTTP代码说明
400invalid_hand手牌格式错误或数量不对
400unsupported_game不支持的玩法
401unauthorizedAPI Key无效或过期
429rate_limited超过每日配额,请升级套餐
500model_error模型推理异常(请重试)

SDK (Python)

# pip install malinguo
from malinguo import MalinguoClient

client = MalinguoClient(api_key="your_key")

# 推荐出牌
advice = client.predict(
    game="sichuan",
    hand=["1m","2m","3m","4p","5p","6p","7s","8s","9s","1z","1z","2z","3z"],
    missing_suit="s"
)
print(advice.best_tile)       # "3z"
print(advice.confidence)      # 0.87
print(advice.explanation)     # "3z是孤立字牌..."
print(advice.alternatives)    # [{"tile":"2z","probability":0.09}, ...]

# 查看所有模型
models = client.list_models()
for m in models:
    print(f"{m.game}: vs_random={m.vs_random:.0%}")

定价

免费版

¥0 /月
  • 100次 API调用/天
  • 6种麻将玩法
  • 标准延迟 (~50ms)
  • 社区支持

企业版

定制
  • 无限API调用
  • 私有化部署
  • 定制模型训练
  • SLA保障 99.9%
  • 专属技术经理

支持的玩法

玩法API代码状态最新vs random胜率
长沙麻将changsha✅ 可用43%
四川麻将sichuan✅ 可用29%
广东麻将guangdong✅ 可用22%
红中麻将hongzhong✅ 可用8%
日本麻将riichi✅ 可用17%
台湾麻将taiwan✅ 可用10%
斗地主doudizhu🔄 训练中-
掼蛋guandan🔄 训练中-
德州扑克texas🔄 训练中-

© 2026 麻邻国 AI · 首页 · AI教练 · dev@malinguo.com