[{"data":1,"prerenderedAt":226},["ShallowReactive",2],{"doc-\u002Fdocs\u002Fapi-gateway-guide":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"body":11,"_type":220,"_id":221,"_source":222,"_file":223,"_stem":224,"_extension":225},"\u002Fdocs\u002Fapi-gateway-guide","docs",false,"","API 中转接入指南","统一接口接入多家大模型服务，本文介绍 API 中转的密钥获取、调用方式与配额管理。","2026-07-10",{"type":12,"children":13,"toc":212},"root",[14,22,29,49,54,60,65,97,103,153,159,164,182,188],{"type":15,"tag":16,"props":17,"children":18},"element","p",{},[19],{"type":20,"value":21},"text","API 中转提供统一的大模型调用入口，一份接口即可访问多家上游模型服务。本文介绍从获取密钥到完成首次调用的完整流程。",{"type":15,"tag":23,"props":24,"children":26},"h2",{"id":25},"一获取-api-密钥",[27],{"type":20,"value":28},"一、获取 API 密钥",{"type":15,"tag":30,"props":31,"children":32},"ol",{},[33,39,44],{"type":15,"tag":34,"props":35,"children":36},"li",{},[37],{"type":20,"value":38},"使用统一账号登录 API 中转控制台",{"type":15,"tag":34,"props":40,"children":41},{},[42],{"type":20,"value":43},"进入「密钥管理」，点击「创建密钥」",{"type":15,"tag":34,"props":45,"children":46},{},[47],{"type":20,"value":48},"为密钥设置名称与可用模型范围，保存后妥善保管密钥串",{"type":15,"tag":16,"props":50,"children":51},{},[52],{"type":20,"value":53},"密钥仅在创建时完整展示一次，请立即复制保存；如遗失请吊销后重新创建。",{"type":15,"tag":23,"props":55,"children":57},{"id":56},"二发起首次调用",[58],{"type":20,"value":59},"二、发起首次调用",{"type":15,"tag":16,"props":61,"children":62},{},[63],{"type":20,"value":64},"API 中转兼容主流大模型的对话接口格式，将请求地址替换为中转入口即可：",{"type":15,"tag":66,"props":67,"children":68},"ul",{},[69,81,92],{"type":15,"tag":34,"props":70,"children":71},{},[72,74],{"type":20,"value":73},"请求地址：",{"type":15,"tag":75,"props":76,"children":78},"code",{"className":77},[],[79],{"type":20,"value":80},"https:\u002F\u002Fapi.yurenai.cn\u002Fv1\u002Fchat\u002Fcompletions",{"type":15,"tag":34,"props":82,"children":83},{},[84,86],{"type":20,"value":85},"鉴权方式：请求头携带 ",{"type":15,"tag":75,"props":87,"children":89},{"className":88},[],[90],{"type":20,"value":91},"Authorization: Bearer \u003C你的密钥>",{"type":15,"tag":34,"props":93,"children":94},{},[95],{"type":20,"value":96},"模型字段：填写控制台「模型列表」中展示的模型标识",{"type":15,"tag":23,"props":98,"children":100},{"id":99},"三流式输出与错误处理",[101],{"type":20,"value":102},"三、流式输出与错误处理",{"type":15,"tag":66,"props":104,"children":105},{},[106,119,148],{"type":15,"tag":34,"props":107,"children":108},{},[109,111,117],{"type":20,"value":110},"设置 ",{"type":15,"tag":75,"props":112,"children":114},{"className":113},[],[115],{"type":20,"value":116},"stream: true",{"type":20,"value":118}," 开启流式输出，按事件流逐段读取",{"type":15,"tag":34,"props":120,"children":121},{},[122,124,130,132,138,140,146],{"type":20,"value":123},"常见错误码：",{"type":15,"tag":75,"props":125,"children":127},{"className":126},[],[128],{"type":20,"value":129},"401",{"type":20,"value":131}," 密钥无效、",{"type":15,"tag":75,"props":133,"children":135},{"className":134},[],[136],{"type":20,"value":137},"429",{"type":20,"value":139}," 触发限流、",{"type":15,"tag":75,"props":141,"children":143},{"className":142},[],[144],{"type":20,"value":145},"5xx",{"type":20,"value":147}," 上游服务异常",{"type":15,"tag":34,"props":149,"children":150},{},[151],{"type":20,"value":152},"建议为客户端实现指数退避重试，幂等处理超时请求",{"type":15,"tag":23,"props":154,"children":156},{"id":155},"四配额与用量管理",[157],{"type":20,"value":158},"四、配额与用量管理",{"type":15,"tag":16,"props":160,"children":161},{},[162],{"type":20,"value":163},"控制台「用量统计」页提供按模型、按密钥维度的调用量与消耗明细：",{"type":15,"tag":30,"props":165,"children":166},{},[167,172,177],{"type":15,"tag":34,"props":168,"children":169},{},[170],{"type":20,"value":171},"支持为单个密钥设置月度配额上限",{"type":15,"tag":34,"props":173,"children":174},{},[175],{"type":20,"value":176},"用量接近上限时可开启邮件提醒",{"type":15,"tag":34,"props":178,"children":179},{},[180],{"type":20,"value":181},"团队空间内可查看各成员的汇总用量",{"type":15,"tag":23,"props":183,"children":185},{"id":184},"五常见问题",[186],{"type":20,"value":187},"五、常见问题",{"type":15,"tag":66,"props":189,"children":190},{},[191,202],{"type":15,"tag":34,"props":192,"children":193},{},[194,200],{"type":15,"tag":195,"props":196,"children":197},"strong",{},[198],{"type":20,"value":199},"是否支持私有模型接入？",{"type":20,"value":201}," 支持，企业版可登记自建推理端点纳入统一路由。",{"type":15,"tag":34,"props":203,"children":204},{},[205,210],{"type":15,"tag":195,"props":206,"children":207},{},[208],{"type":20,"value":209},"计费粒度是什么？",{"type":20,"value":211}," 按上游模型的 token 用量计费，明细可在账单页导出。",{"title":7,"searchDepth":213,"depth":213,"links":214},2,[215,216,217,218,219],{"id":25,"depth":213,"text":28},{"id":56,"depth":213,"text":59},{"id":99,"depth":213,"text":102},{"id":155,"depth":213,"text":158},{"id":184,"depth":213,"text":187},"markdown","content:docs:api-gateway-guide.md","content","docs\u002Fapi-gateway-guide.md","docs\u002Fapi-gateway-guide","md",1789785271240]