← Docs/

§ 快速开始 · SDK

Python · TypeScript SDK.

类型化字段, 内置 auth / 重试 / error 类映射. Python (httpx + Pydantic v2) / TypeScript (native fetch, ESM + CJS 双 build).

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 映射到具体异常类:

服务端 codePython 类TypeScript 类HTTP
INVALID_CODE_FORMATBadRequestErrorBadRequestError400
INVALID_API_KEYAuthenticationErrorAuthenticationError401
ENDPOINT_NOT_ALLOWEDPermissionDeniedErrorPermissionDeniedError403
BYOM_NOT_ALLOWEDPermissionDeniedErrorPermissionDeniedError403
RATE_LIMIT_EXCEEDEDRateLimitErrorRateLimitError429
QUOTA_EXCEEDEDQuotaExceededErrorQuotaExceededError429
LLM_PROVIDER_ERRORBadGatewayErrorBadGatewayError502
LLM_TIMEOUTGatewayTimeoutErrorGatewayTimeoutError504

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_keyHIPMM_API_KEY(必填)
base_urlHIPMM_BASE_URLhttps://api.hipmm.com
timeout60 秒
max_retries2 (5xx / 429 自动重试)