{"article":{"title":"Quickstart","breadcrumb":["Getting started","Quickstart"],"body":"**What this solves**: How to send your first successful model request with Tare.\n\nIf you don't have an account or key yet, read [Before you start](before-key) first. If you already have an Inference key, just follow the steps below.\n\n### What you need to prepare\n\n- A working Tare account.\n- An **Inference key**. Be careful not to use a Provisioning key or a Reconciliation key; the three key types have different permissions, and the wrong type gets rejected outright.\n- A working model name, such as one visible in the console or in `GET /v1/models`.\n- Your server can reach `https://tare.jamerly.ai`.\n\n> [!NOTE]\n> The full key plaintext **is shown only once, at creation time**; the platform stores only a hash, and the list then shows only a mask like `ak-…3f2a`. Save it in your server-side secret management system, not in browser frontend code.\n\n### 1. Create an Inference key\n\nConsole path:\n\n```text\nConsole → Tare → API Keys → Create\n```\n\nChoose **Inference** as the type. Write the name so its purpose is clear, for example `support-bot-production`. After creating it you'll see the full key; copy and save it.\n\n### 2. Change two configs, send a request\n\nAny OpenAI-compatible client works by changing these two configs:\n\n| Config | Value |\n|---|---|\n| `base_url` | `https://tare.jamerly.ai/v1` |\n| `api_key` | Your Inference key |\n\n#### curl\n\n```bash\ncurl 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```\n\n#### Python (OpenAI SDK)\n\n```python\nimport 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```\n\n#### Which name to put in `model`\n\nPut the **platform-side model name**, not the name on the upstream provider's side. Tare is responsible for mapping between the two.\n\n> [!NOTE]\n> The response always carries the name you requested. Even if a failover switches the upstream mid-flight, you never receive a model name you didn't request.\n\n### 3. How to tell you're connected\n\n- HTTP returns 200.\n- The model produced content.\n- The response headers include `X-Generation-Id`, or the response contains a `gen-...` ID.\n- Later you can use `GET /v1/generation?id=gen-...` to check this call's cost and latency.\n\n> [!NOTE]\n> Querying **immediately** after getting the ID may return 404, because the usage record is written after the response. **Treat any 404 within 60 seconds of receiving the ID as \"not written yet, check again later\".**\n\n### 4. Streaming calls\n\nPass `stream: true` in the request; it returns an SSE stream ending with `data: [DONE]`.\n\n**Two kinds of upstream API don't natively send this terminator: Anthropic and OpenAI's own Responses API. Tare adds it for you in both cases.** Without it, a client that hand-parses SSE (rather than a standard SDK that recognizes each vendor's own end-of-stream signal) will keep waiting after the last frame of real content.\n\n> [!TIP]\n> Usage is in the **last frame**. Tare forces `stream_options.include_usage` on and overrides your setting, because without usage there's no billing or attribution.\n\n> [!WARNING]\n> **Before the first byte, you may receive several SSE comments (lines starting with `:`).**\n>\n> For calls with large inputs, the upstream has to finish reading the prompt before it starts generating, so the first byte can take tens of seconds (in measurements, a good number beyond the median exceed 10 seconds, with the slowest approaching 80 seconds). During this time there are no bytes on the connection, and the client and proxies along the way will treat it as a dead connection and kill it. After about 5 seconds of silence, Tare starts sending an SSE comment every few seconds, so every hop knows the connection is still alive.\n>\n> The SSE spec requires parsers to **ignore** lines starting with `:`, so standard SDKs need to do nothing. **Only hand-written parsing clients need to pay attention**: don't treat comment lines as data frames to JSON-parse. The last frame may also contain only usage, with no renderable text.\n\n![Streaming calls: the silence before the first byte, and why Tare sends comments for the upstream](diagram:en-quickstart-sse-sequence)\n\n### Common issues\n\n| Symptom | Common cause | What to do |\n|---|---|---|\n| 401 | Key doesn't exist, is disabled, or has expired | Reconfirm the key plaintext and its state |\n| 403 | Wrong key type, or a quota / budget / source IP / DLP block | First confirm it's an Inference key, then check `metadata.refusal_reason` |\n| 404 | No route configured for the model name, or the record isn't written yet | Check `GET /v1/models`; generation queries can be retried within 60 seconds |\n| 429 | Rate limit triggered | Retry per `Retry-After` |\n| Streaming stalls | Hand-written parser doesn't ignore comment lines, or a proxy timeout | Ignore lines starting with `:`; check the proxy's SSE config |\n\n### Next steps\n\n- To use Tare from coding tools such as Claude Code, Codex or Cursor: read [Coding tools](coding-tools).\n- To connect your own provider: read [Channels](channels).\n- To make a given model go through a chosen channel: read [Routing](routing).\n- To break down cost by customer or business line: read [Cost attribution](attribution).\n"},"diagrams":{"en-quickstart-sse-sequence":"<svg viewBox=\"0 0 700 421\" width=\"700\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\">\n  <title>Streaming: Tare comments before the first byte</title>\n  <desc>After stream:true, Tare forwards the request and, once the upstream has been silent for about 5 seconds, sends an SSE comment every few seconds until the first content frame. The final frame carries usage only, then data: [DONE].</desc>\n  <style>\n    text { font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', system-ui, sans-serif; }\n  </style>\n  <defs>\n    <marker id=\"arrow-blue\" markerWidth=\"8\" markerHeight=\"8\" refX=\"2\" refY=\"4\" orient=\"auto\" markerUnits=\"userSpaceOnUse\">\n      <path d=\"M0,0 L8,4 L0,8 L2,4 z\" fill=\"#3b82f6\"/>\n    </marker>\n    <marker id=\"arrow-orange\" markerWidth=\"8\" markerHeight=\"8\" refX=\"2\" refY=\"4\" orient=\"auto\" markerUnits=\"userSpaceOnUse\">\n      <path d=\"M0,0 L8,4 L0,8 L2,4 z\" fill=\"#f59e0b\"/>\n    </marker>\n    <marker id=\"arrow-green\" markerWidth=\"8\" markerHeight=\"8\" refX=\"2\" refY=\"4\" orient=\"auto\" markerUnits=\"userSpaceOnUse\">\n      <path d=\"M0,0 L8,4 L0,8 L2,4 z\" fill=\"#22c55e\"/>\n    </marker>\n  </defs>\n\n  <!-- 浅色画布 -->\n  <rect x=\"0\" y=\"0\" width=\"700\" height=\"421\" fill=\"#ffffff\"/>\n\n  <!-- 版式算术：\n       三位参与者并排，宽 200、间距 28，于是 22..222 / 250..450 / 478..678，\n       生命线落在各框中心 122 / 350 / 578。\n       消息行从 130 起，行距 32；七条消息，末行 322，生命线收到 344。\n       标签压在消息线上方 13px——标签下沿离线的净距 11.5px，上沿离上一条线 10.5px，\n       两边都在 10px 的净距要求之上（-7px 那次实测只有 4.5px，被质检拦下）。\n       内容左右边界 22..678，中心 350；viewBox 宽 = 656 + 两侧各 22 = 700。\n       高度 = 脚注末行基线 396 + 下伸 2.5 + 22px 边距 = 420.5，取整 421。 -->\n\n  <text x=\"350\" y=\"34\" font-size=\"16\" fill=\"#1e293b\" text-anchor=\"middle\">Streaming: Tare comments before the first byte</text>\n\n  <!-- 参与者 -->\n  <rect x=\"22\" y=\"60\" width=\"200\" height=\"36\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"122\" y=\"82\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">Your client</text>\n  <rect x=\"250\" y=\"60\" width=\"200\" height=\"36\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"350\" y=\"82\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">Tare</text>\n  <rect x=\"478\" y=\"60\" width=\"200\" height=\"36\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"578\" y=\"82\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">Upstream</text>\n\n  <!-- 生命线：虚线、无箭头（有箭头就会被当成消息） -->\n  <path d=\"M122,101 L 122,344\" fill=\"none\" stroke=\"#94a3b8\" stroke-dasharray=\"6,4\"/>\n  <path d=\"M350,101 L 350,344\" fill=\"none\" stroke=\"#94a3b8\" stroke-dasharray=\"6,4\"/>\n  <path d=\"M578,101 L 578,344\" fill=\"none\" stroke=\"#94a3b8\" stroke-dasharray=\"6,4\"/>\n\n  <!-- 消息：右行起点 = 源生命线 + 5，终点 = 目标生命线 - 11；\n       左行起点 = 源生命线 - 5，终点 = 目标生命线 + 11。 -->\n  <path d=\"M127,130 L 339,130\" fill=\"none\" stroke=\"#3b82f6\" stroke-width=\"1.5\" marker-end=\"url(#arrow-blue)\"/>\n  <text x=\"233\" y=\"117\" font-size=\"10\" fill=\"#1e293b\" text-anchor=\"middle\">stream: true</text>\n\n  <path d=\"M355,162 L 567,162\" fill=\"none\" stroke=\"#3b82f6\" stroke-width=\"1.5\" marker-end=\"url(#arrow-blue)\"/>\n  <text x=\"461\" y=\"149\" font-size=\"10\" fill=\"#1e293b\" text-anchor=\"middle\">Forward (include_usage on)</text>\n\n  <path d=\"M345,194 L 133,194\" fill=\"none\" stroke=\"#f59e0b\" stroke-width=\"1.5\" marker-end=\"url(#arrow-orange)\"/>\n  <text x=\"239\" y=\"181\" font-size=\"10\" fill=\"#b45309\" text-anchor=\"middle\">A ':' comment every few seconds</text>\n\n  <path d=\"M573,226 L 361,226\" fill=\"none\" stroke=\"#22c55e\" stroke-width=\"1.5\" marker-end=\"url(#arrow-green)\"/>\n  <text x=\"467\" y=\"213\" font-size=\"10\" fill=\"#166534\" text-anchor=\"middle\">First content frame</text>\n\n  <path d=\"M345,258 L 133,258\" fill=\"none\" stroke=\"#22c55e\" stroke-width=\"1.5\" marker-end=\"url(#arrow-green)\"/>\n  <text x=\"239\" y=\"245\" font-size=\"10\" fill=\"#166534\" text-anchor=\"middle\">Data frames</text>\n\n  <path d=\"M345,290 L 133,290\" fill=\"none\" stroke=\"#22c55e\" stroke-width=\"1.5\" marker-end=\"url(#arrow-green)\"/>\n  <text x=\"239\" y=\"277\" font-size=\"10\" fill=\"#166534\" text-anchor=\"middle\">Final frame: usage only</text>\n\n  <path d=\"M345,322 L 133,322\" fill=\"none\" stroke=\"#22c55e\" stroke-width=\"1.5\" marker-end=\"url(#arrow-green)\"/>\n  <text x=\"239\" y=\"309\" font-size=\"10\" fill=\"#166534\" text-anchor=\"middle\">data: [DONE]</text>\n\n  <!-- 脚注：静默期的量级、注释行该怎么处理、以及 [DONE] 为什么要由 Tare 补。 -->\n  <text x=\"350\" y=\"366\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">Upstream can stay silent for tens of seconds, up to ~80s. After ~5s, Tare comments every few seconds.</text>\n  <text x=\"350\" y=\"381\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">Comments start with ':'. SSE parsers ignore them. Do not JSON-parse them in a hand-written client.</text>\n  <text x=\"350\" y=\"396\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">Anthropic and OpenAI Responses do not send data: [DONE]. Tare adds it for both.</text>\n</svg>\n"}}