PY
Python SDK
bash
pip install hipmm # 当前 v0.3.0 · Python ≥ 3.10
同步 · with 上下文管理
from hipmm import HiPMM
with HiPMM(api_key="hipmm_sk_...") as client:
result = client.codename.create("I-A-L-X-ID-AR(PR)-SE-LT")
print(result.data.short) # 深思的孤勇者
print(result.data.long) # 深思的颠覆者 · 孤勇者
print(result.metadata.request_id)异步 · AsyncHiPMM
import asyncio
from hipmm import AsyncHiPMM
async def main():
async with AsyncHiPMM(api_key="hipmm_sk_...") as client:
sym = await client.codename.symbolic("I-A-L-X-ID-AR(PR)-SE-LT")
print(sym.data.symbolic) # 深渊灯塔
asyncio.run(main())个体画像 + BYOM
from hipmm import HiPMM, LLMConfig
client = HiPMM(api_key="hipmm_sk_...")
result = client.analyze.individual(
code="I-A-L-X-ID-AR(PR)-SE-LT",
depth="deep",
llm_config=LLMConfig(
mode="byom_proxy",
provider="anthropic",
model="claude-opus-4-7",
api_key="sk-ant-客户自己的",
base_url="https://api.anthropic.com",
),
)TS
TypeScript SDK
bash
npm install hipmm # 当前 v0.3.0 · Node ≥ 18 / Edge / 浏览器均可
async/await · native fetch
import { HiPMM } from "hipmm";
const client = new HiPMM({ apiKey: "hipmm_sk_..." });
const result = await client.codename.create({
code: "I-A-L-X-ID-AR(PR)-SE-LT",
});
console.log(result.data.short); // 深思的孤勇者BYOM 模式
const report = await client.analyze.individual({
code: "I-A-L-X-ID-AR(PR)-SE-LT",
depth: "standard",
llmConfig: {
mode: "byom_proxy",
provider: "deepseek",
api_key: "sk-客户自己的",
base_url: "https://api.deepseek.com/v1",
},
});Edge / 浏览器
SDK 走 native fetch, 无 Node-specific 依赖. Cloudflare Workers, Vercel Edge, Deno, 浏览器都能用. 注入自定义 fetch (代理 / 拦截) 通过
new HiPMM({ apiKey, fetch: customFetch }).ERR
错误处理
SDK 把服务端 error_code 映射到具体异常类:
| 服务端 code | Python 类 | TypeScript 类 | HTTP |
|---|---|---|---|
| INVALID_CODE_FORMAT | BadRequestError | BadRequestError | 400 |
| INVALID_API_KEY | AuthenticationError | AuthenticationError | 401 |
| ENDPOINT_NOT_ALLOWED | PermissionDeniedError | PermissionDeniedError | 403 |
| BYOM_NOT_ALLOWED | PermissionDeniedError | PermissionDeniedError | 403 |
| RATE_LIMIT_EXCEEDED | RateLimitError | RateLimitError | 429 |
| QUOTA_EXCEEDED | QuotaExceededError | QuotaExceededError | 429 |
| LLM_PROVIDER_ERROR | BadGatewayError | BadGatewayError | 502 |
| LLM_TIMEOUT | GatewayTimeoutError | GatewayTimeoutError | 504 |
Python · except 链
from hipmm import (
HiPMMError, AuthenticationError, RateLimitError, QuotaExceededError
)
try:
result = client.codename.create("invalid")
except QuotaExceededError:
print("月度配额已用尽")
except RateLimitError:
print("被限流, 稍后重试")
except AuthenticationError:
print("API key 无效")
except HiPMMError as e:
print(f"其他: {e.status_code} {e.code} {e.message}")CFG
配置 (env)
| 参数 | env var | 默认 |
|---|---|---|
| api_key | HIPMM_API_KEY | (必填) |
| base_url | HIPMM_BASE_URL | https://api.hipmm.com |
| timeout | — | 60 秒 |
| max_retries | — | 2 (5xx / 429 自动重试) |