{"type":"root","children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"这篇解决什么问题"}]},{"type":"text","value":"：让你用 Tare 发出第一条成功的模型请求。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"如果你还没有账号或 key，先读 "},{"type":"element","tagName":"a","properties":{"href":"before-key"},"children":[{"type":"text","value":"开始之前"}]},{"type":"text","value":"。已经拿到 Inference key（推理 key）的话，照着下面走就行。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"你需要准备什么"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"一个可用的 Tare 账号。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"一把 "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Inference key（推理 key）"}]},{"type":"text","value":"。注意别用 Provisioning key（母钥）或 Reconciliation key（对账 key），三类 key 权限不同，用错类型会被直接拒绝。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"一个可用的模型名，例如控制台里或 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"GET /v1/models"}]},{"type":"text","value":" 里能看到的模型。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"你的服务端能访问 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"https://tare.jamerly.ai"}]},{"type":"text","value":"。"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"note"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"完整的 key 明文"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"只在创建时显示一次"}]},{"type":"text","value":"，平台只存哈希，列表里之后只显示 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"ak-…3f2a"}]},{"type":"text","value":" 这样的掩码。请把它保存到服务端的密钥管理系统，不要放在浏览器前端。"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"1. 创建 Inference key"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"控制台路径："}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-text"]},"children":[{"type":"text","value":"Console → Tare → API Keys → Create\n"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"类型选 "},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"Inference"}]},{"type":"text","value":"。名称建议写清用途，例如 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"support-bot-production"}]},{"type":"text","value":"。创建后你会看到完整 key，复制保存即可。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"2. 改两个配置，发出请求"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"任何 OpenAI 兼容的客户端，改这两个配置就能用："}]},{"type":"text","value":"\n"},{"type":"element","tagName":"table","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"thead","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"配置"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"值"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"base_url"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"https://tare.jamerly.ai/v1"}]}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"api_key"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"你的 Inference key"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{},"children":[{"type":"text","value":"curl"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-bash"]},"children":[{"type":"text","value":"curl https://tare.jamerly.ai/v1/chat/completions \\\n  -H \"Authorization: Bearer $TARE_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"GLM 5.1\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"hello\"}]\n  }'\n"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{},"children":[{"type":"text","value":"Python（OpenAI SDK）"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"pre","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["language-python"]},"children":[{"type":"text","value":"import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url=\"https://tare.jamerly.ai/v1\",\n    api_key=os.environ[\"TARE_API_KEY\"],\n)\n\nresp = client.chat.completions.create(\n    model=\"GLM 5.1\",\n    messages=[{\"role\": \"user\", \"content\": \"hello\"}],\n)\nprint(resp.choices[0].message.content)\n"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h4","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"model"}]},{"type":"text","value":" 里填哪个名字"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"填"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"平台侧的模型名"}]},{"type":"text","value":"，不是上游供应商那边的名字。两边怎么对应，由 Tare 负责。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"note"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"回包里始终是你请求的那个名字。即使中途故障转移换了上游，你也不会收到一个自己没请求过的模型名。"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"3. 怎么判断已经接通"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"HTTP 返回 200。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"模型给出了内容。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"响应头里有 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"X-Generation-Id"}]},{"type":"text","value":"，或者回包里出现了 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"gen-..."}]},{"type":"text","value":" 编号。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"稍后可以用 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"GET /v1/generation?id=gen-..."}]},{"type":"text","value":" 查这次调用的成本与耗时。"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"note"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"拿到编号后"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"立刻"}]},{"type":"text","value":"查询可能返回 404，因为用量记录是在响应之后才写入的。"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"收到编号后 60 秒内的 404 一律按「还没写入，稍后再查」处理。"}]}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"4. 流式调用"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"请求里传 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"stream: true"}]},{"type":"text","value":"，返回 SSE 流，以 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"data: [DONE]"}]},{"type":"text","value":" 结束。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"有两种上游接口原生不发这个结束符：Anthropic 和 OpenAI 自己的 Responses API。这两种 Tare 都会替你补上。"}]},{"type":"text","value":" 少了它，手写 SSE 解析的客户端（不像标准 SDK 那样认得各家自己的流结束信号）会在最后一帧真实内容之后一直等下去。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"tip"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"用量在"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"最后一帧"}]},{"type":"text","value":"。Tare 会强制打开 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"stream_options.include_usage"}]},{"type":"text","value":" 并覆盖你的设置，没有用量就无法计费和归因。"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"blockquote","properties":{"data-alert":"warning"},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"首字节之前，你可能先收到若干 SSE 注释（以 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":":"}]},{"type":"text","value":" 开头的行）。"}]}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"大输入的调用里，上游要先把提示词读完才开始生成，首字节可能等上几十秒（实测中位数之外有相当一部分超过 10 秒，最慢接近 80 秒）。这段时间连接上没有任何字节，客户端和沿途的代理会把它当成一条死连接掐掉。Tare 在静默约 5 秒后，开始每隔几秒发一个 SSE 注释，让每一跳都知道连接还活着。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"SSE 规范要求解析器"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"忽略"}]},{"type":"text","value":"以 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":":"}]},{"type":"text","value":" 开头的行，所以标准 SDK 不用做任何事。"},{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"只有手写解析的客户端需要注意"}]},{"type":"text","value":"：不要把注释行当成数据帧去 JSON 解析。最后一帧也可能只有 usage、没有可渲染文本。"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"img","properties":{"src":"diagram:quickstart-sse-sequence","alt":"流式调用：首字节之前的那段静默，以及 Tare 为什么替上游发注释","data-block":"true"},"children":[]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"常见问题"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"table","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"thead","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"现象"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"常见原因"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"处理方式"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"401"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"key 不存在、已停用或已过期"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"重新确认 key 明文和状态"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"403"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"key 类型不对，或额度 / 预算 / 来源 IP / DLP 拦截"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"先确认是不是 Inference key，再看 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"metadata.refusal_reason"}]}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"404"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"模型名没有配置路由，或记录尚未写入"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"查 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"GET /v1/models"}]},{"type":"text","value":"；generation 查询在 60 秒内可重试"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"429"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"触发限流"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"按 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"Retry-After"}]},{"type":"text","value":" 重试"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"流式卡住"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"手写解析器没有忽略注释行，或代理超时"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"忽略 "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":":"}]},{"type":"text","value":" 开头的行；检查代理的 SSE 配置"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"h3","properties":{},"children":[{"type":"text","value":"下一步"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"要在 Claude Code、Codex、Cursor 这类编程工具里用：读 "},{"type":"element","tagName":"a","properties":{"href":"coding-tools"},"children":[{"type":"text","value":"在编程工具里使用"}]},{"type":"text","value":"。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"要接自己的供应商：读 "},{"type":"element","tagName":"a","properties":{"href":"channels"},"children":[{"type":"text","value":"渠道"}]},{"type":"text","value":"。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"要让某个模型走指定渠道：读 "},{"type":"element","tagName":"a","properties":{"href":"routing"},"children":[{"type":"text","value":"路由"}]},{"type":"text","value":"。"}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"要按客户或业务线拆成本：读 "},{"type":"element","tagName":"a","properties":{"href":"attribution"},"children":[{"type":"text","value":"成本归因"}]},{"type":"text","value":"。"}]},{"type":"text","value":"\n"}]}]}