{"article":{"title":"Cost prices","breadcrumb":["Upstream channels","Cost prices"],"body":"**What this solves**: Enter the prices you pay your upstream vendors into Tare so cost attribution can be computed.\n\nA **cost price** is the price you pay your upstream vendor. It plays no part in what you are charged: for your own channels you already pay the vendor directly for the tokens; what it decides is **whether cost attribution can be computed**.\n\nCost prices are used only for cost attribution and have nothing to do with whether a call is allowed. Not entering cost prices usually doesn't affect calls, but it leaves the cost column empty.\n\n### When you need to enter cost prices\n\nThe priority order for accounting:\n\n1. **The real cost reported in the upstream response** (the true value of each call).\n2. Only when the upstream doesn't report cost does it fall back to the cost price you enter here.\n\nIn other words:\n\n- The upstream reports real cost in every response: **the cost price table is not used at all**, and you get accurate attribution numbers without entering a single row.\n- The upstream reports only token counts, not cost: you need to enter cost prices.\n- Self-hosted inference services, some proxies, and local models: usually need cost prices entered.\n\n![When you need to enter cost prices: it only comes into play when the upstream doesn't report cost](diagram:en-cost-prices-need-cost)\n\n### What happens if you don't enter cost prices\n\nCalls and billing are unaffected; what is affected is the cost column in cost analysis.\n\nIn Analytics, Cost attribution, or a generation query, you will see some calls with a token count but an empty cost. The system can only tell you:\n\n```text\nKnown cost this month: ¥1,234\nCost coverage: 62%\n```\n\n> [!WARNING]\n> Coverage is given together with the amount. \"Cost this month ¥1,234 (62% covered)\" means 38% of calls still have no cost data.\n> **These calls do have a cost; the platform just has no way to know it**. Calculating margin from numbers that aren't fully covered will be optimistic.\n\n![What happens if you don't enter cost prices: coverage points out that 38%](diagram:en-cost-prices-coverage)\n\nThe channel page lists models missing a cost price, and the same list is also available at `GET /v1/providers/{id}/missing-costs`.\n\n### Where to enter them\n\nConsole path:\n\n```text\nConsole → Tare → Channels → expand a channel → Cost prices\n```\n\nThe Cost prices table is inside the channel's expanded area, not a separate page. That's because a cost price always belongs to a specific upstream channel.\n\n### How to fill in the fields\n\n| Field | Meaning | Note |\n|---|---|---|\n| Upstream model | The model name the upstream recognizes | Not the model name used when calling Tare |\n| Input | Price per million input tokens | prompt/input price |\n| Output | Price per million output tokens | completion/output price |\n| Cache read | Price per million for cache reads | Don't fill in randomly if unsure |\n| Cache write | Price per million for cache writes | Don't fill in randomly if unsure |\n\n**All four values are per million tokens**, and the cache read/write prices are optional.\n\nFor example, if the vendor writes:\n\n```text\nInput: $0.20 / 1M tokens\nOutput: $0.80 / 1M tokens\n```\n\nYou enter:\n\n```text\nInput = 0.2\nOutput = 0.8\n```\n\n### The easiest thing to get wrong: the model name\n\n`Upstream model` must be the model name **on the upstream side**, not the name used when calling Tare.\n\nExample:\n\n```text\nCaller requests model = GLM 5.1\nRouting points to openrouter-prod / z-ai/glm-5.1\nCost prices must also record z-ai/glm-5.1\n```\n\nDon't enter `GLM 5.1` into this channel's cost price table, unless that is really the name the upstream recognizes.\n\n> [!WARNING]\n> A wrong model name usually doesn't raise an error. It simply never matches, and that model's cost is permanently empty.\n\n**Prefer Browse upstream models on the Channels page** (`GET /v1/providers/{id}/upstream-models`) to avoid manual entry. The model list you fetch is a suggested list, not an allowlist; when private models, canary models, or aliases can't be fetched, you can still enter them manually.\n\nWhere the upstream publishes prices, the browse list shows them per 1M tokens, in the currency the upstream quotes (OpenRouter quotes USD). Nothing is converted. If you negotiated other rates or are billed in another currency, edit the rows after adding them.\n\n> [!NOTE]\n> This endpoint fails gracefully (upstream doesn't support listing a catalog, address can't be derived, key only has chat permission) and always returns `200` with an explanatory sentence, not an error code.\n\n### Tiers, per-request prices and multipliers\n\nOpen **Edit** on a cost price for the parts that a flat per-million price cannot express:\n\n| Setting | Meaning |\n|---|---|\n| Conditional rules | Another set of prices for calls that match. A rule can look at the input length (above a threshold, at most an upper bound), the time of day (days of the week and a `[from, to)` range in a timezone; the end is exclusive and must be later than the start, `00:00` means end of day, and a cross-midnight window is split into two) and a validity period. When several rules match, the highest priority wins. A matching rule prices the **whole call**, not only the part above the threshold. |\n| Image / audio prices | Per-million prices for image and audio tokens in the input or output. Leave them empty and those tokens are priced as ordinary input or output. |\n| Per request | Bill each call at a fixed USD amount instead of by tokens. Image generation multiplies it by the number of images. A rule can switch to per request too, for example short prompts at a flat price. |\n| Multipliers | Multiply the cost of a call when a request header or body parameter matches, for example `anthropic-beta` contains `fast-mode` ×6, or `service_tier` equals `priority` ×2. A multiplier can also apply to a time window or a validity period. Several matching multipliers multiply together. Tool fees are not multiplied. |\n\nThe usage record shows which rule and multipliers priced a call, for example `long_context*fast-mode`.\n\n### The difference between empty and 0\n\nIn the form, leaving a field empty is saved as **0**, not recorded as \"unknown\".\n\nThere's a trap here:\n\n- The vendor explicitly says something is free: entering 0 is correct.\n- You don't know the price: **don't record the whole row**.\n\nA missing cost price is something the system can remind you about through \"coverage\"; a wrong 0 is hard to spot and will make the cost too low.\n\n### Saving, editing, deleting\n\n#### Adding\n\nEnter the model name and the four prices at the bottom of the Cost prices table, then click **Save**.\n\n#### Editing\n\nClick **Edit** on a row, make the changes, and save.\n\nSaving an existing model name overwrites it. That is, if you only want to change the Input price, keep the other three at their original values rather than clearing them.\n\n#### Deleting\n\nClick **Remove** to delete a model's cost price. After deletion, later calls that don't match this model's price have an unknown cost again.\n\n### Bulk importing a vendor price list\n\nThe Channels page supports importing cost prices by reading a price list: a screenshot of a per-brand discount table from a reseller, or price table text you paste, so you don't have to enter models one by one manually.\n\nGood for these cases:\n\n- The reseller gave you a per-brand discount table.\n- You have a screenshot of prices.\n- You have a chunk of price table text.\n- There are many models and you don't want to fill them in row by row manually.\n\nHow it works:\n\n1. Choose the vendor group to import into, or all channels.\n2. Choose a multimodal model on one of your own channels to parse the image or text.\n3. Upload the screenshot or paste the price table.\n4. Tare sends the image/text to the model you chose and has it extract structured prices.\n5. Tare compares them against existing cost prices and reference prices, and shows the differences.\n6. Nothing is written until you confirm.\n\n> [!NOTE]\n> This step reuses the **Chat** diagnostic endpoint from the channel page: it consumes real upstream tokens on the channel you chose to parse with, but this parse call itself **is not billed by Tare and does not appear in Call Traces**, the same rule as manually testing a channel.\n\n> [!WARNING]\n> Bulk import is not \"trust everything automatically\". You must look at the difference preview before importing, especially the currency, unit, discount multiplier, and cache prices.\n\n### Cost prices have no effective period\n\nThe platform **keeps only the current price** and the time it was entered; it does not keep historical price ranges.\n\n> [!WARNING]\n> After a price change, recomputing historical calls uses the new price, not the price at the time. This is a clear source of deviation in **monthly reconciliation**.\n\nThis means:\n\n- After you change a price today, recomputing historical calls uses the new price.\n- Historical calls that previously had no price will also use the current price when they are backfilled.\n- If the vendor changes prices mid-way, monthly reconciliation may deviate.\n\nBefore effective periods are supported, it's best to do this:\n\n1. Record the time of the price change on the day it happens.\n2. When reconciling, split before and after the change date and check the two segments separately.\n3. For upstreams where you can use the real cost reported in the upstream response, prefer the real cost, because that path is unaffected and every call records the true value for that call.\n\nThere is no confirmed date for effective period support.\n\n### What `recorded_at` is\n\nThe cost price read endpoint returns `recorded_at` (ISO 8601, e.g. `2026-08-21T17:30:00`), which is **refreshed on every price change**.\n\nIt means \"**when the current** price was entered\", not the creation time of the record, not when the price takes effect, and certainly not when the model first appeared.\n\nIts use is reconciliation. Cost prices have no effective period, so backfilling historical cost always uses the current price; with this field, you can at least tell which version of the price was used when reconciling a given month. A price entered after the change date is used to backfill calls before the change date, and that segment of numbers is off; without this field, that is completely invisible on a report.\n\n> [!WARNING]\n> **For historical data this field is `null`** (this column was added later). `null` means the entry time is unknown, so **don't default it to today's date on your side**, which would make an unverified deviation look verified.\n\n### What automatic backfill can do\n\nThe platform has two kinds of automatic behavior:\n\n- **Backfill calls that already happened after you enter a cost price.** Calls that previously had no price get a cost added, so you don't lose this history just because you entered the cost price late.\n- **Read the upstream price list once an hour.** Backfill models you have used but not priced.\n\n> [!WARNING]\n> Backfilling historical calls uses the **current** price, not the price at the time the call happened (see \"Cost prices have no effective period\" above).\n\nWhat it reads automatically is the vendor's published list price:\n\n- In the currency the vendor publishes, **with no exchange rate conversion**.\n- It may not include your contract discount.\n- It **never overwrites prices you entered manually**.\n\nSo if you have a contract price, a discounted price, or a special channel price, manual entry should take precedence.\n\n### How the endpoints relate to the console\n\nThese endpoints all use a console login session, not an inference API key:\n\n| Action | Endpoint |\n|---|---|\n| Read cost prices | `GET /v1/providers/{id}/costs` |\n| Save cost prices | `PUT /v1/providers/{id}/costs` |\n| Delete a cost price | `POST /v1/providers/{id}/costs/delete` |\n| Check models missing a cost price | `GET /v1/providers/{id}/missing-costs` |\n| Fetch the upstream model list | `GET /v1/providers/{id}/upstream-models` |\n\n### SOP: filling in cost prices for one channel\n\n1. Open **Channels**.\n2. Expand the channel to configure.\n3. Click **Browse upstream models**.\n4. Choose the models to use from the list; if you can't fetch it, enter the upstream model name manually.\n5. Fill in Input, Output, Cache read, and Cache write against the vendor's price list.\n6. Don't enter models you are unsure about.\n7. After saving, check whether the missing cost warning is gone.\n8. Send one real request.\n9. In Analytics or a generation query, confirm the cost is no longer empty.\n\n### Minimal acceptance checklist\n\n- [ ] You have confirmed which upstreams report real cost in their response and which need cost prices entered manually.\n- [ ] Every BYOK channel that will carry traffic has its corresponding upstream model names entered.\n- [ ] Model names use the upstream names, not the external Tare model names.\n- [ ] All four prices are per million tokens.\n- [ ] Unknown prices were not entered as 0.\n- [ ] When changing a price you recorded the change date, knowing that historical backfill uses the current price.\n- [ ] In the cost attribution page or a generation query, the cost of the target calls is not empty.\n\n### Next steps\n\nThese three articles are one chain; read them in order: **connect a channel → enter cost prices → configure routing**. You have just finished the second step.\n\n- Previous: if you don't have a channel yet, read [channels](channels) first.\n- Next: point the external model name at this channel, read [Routing](routing).\n- To find out where the cost goes: read [Cost attribution](attribution).\n- For a word you don't recognize: look it up in the [glossary](glossary).\n"},"diagrams":{"en-cost-prices-need-cost":"<svg viewBox=\"0 0 708 366\" width=\"708\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\">\n  <title>Enter a cost price only when upstream omits cost</title>\n  <desc>Use the upstream's reported cost when the response includes it. Enter a cost price only when the upstream returns tokens and no fee. Leave a row out when the price is unknown. A blank is stored as 0.</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  </defs>\n\n  <!-- 浅色画布 -->\n  <rect x=\"0\" y=\"0\" width=\"700\" height=\"366\" fill=\"#ffffff\"/>\n\n  <!-- 版式算术：\n       根框横跨整行 22..678（宽 656），两个分支框并排在下一行，宽 318、间距 28，\n       于是 22..340 / 368..686。根框横跨是为了让两条分支线全竖直下行。\n       行顶边 60 / 142，底边 114 / 214；根框 54 高（两行），分支框 72 高（三行）。\n       最下面那条是提醒，不是流程里的一步，所以不画连线。\n       内容左右边界 22..686，中心 354；viewBox 宽 = 664 + 两侧各 22 = 708 → 取 700 会把右边压到 686+22=708，\n       故宽度取 708。\n       高度 = 脚注末行基线 341 + 下伸 2.5 + 22px 边距 = 365.5，取整 366。 -->\n\n  <text x=\"354\" y=\"34\" font-size=\"16\" fill=\"#1e293b\" text-anchor=\"middle\">Enter a cost price only when upstream omits cost</text>\n\n  <path d=\"M181,119 L 181,131\" fill=\"none\" stroke=\"#3b82f6\" stroke-width=\"1.5\" marker-end=\"url(#arrow-blue)\"/>\n  <path d=\"M527,119 L 527,131\" fill=\"none\" stroke=\"#3b82f6\" stroke-width=\"1.5\" marker-end=\"url(#arrow-blue)\"/>\n\n  <rect x=\"22\" y=\"60\" width=\"664\" height=\"54\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"354\" y=\"82\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">Where does this call's cost come from?</text>\n  <text x=\"354\" y=\"100\" font-size=\"10\" fill=\"#1e40af\" text-anchor=\"middle\">Order: the cost in the upstream response, then the price you entered</text>\n\n  <rect x=\"22\" y=\"142\" width=\"318\" height=\"72\" rx=\"6\" fill=\"#d1fae5\" stroke=\"#22c55e\"/>\n  <text x=\"181\" y=\"165\" font-size=\"12\" fill=\"#166534\" text-anchor=\"middle\">Upstream reports real cost every time</text>\n  <text x=\"181\" y=\"183\" font-size=\"10\" fill=\"#166534\" text-anchor=\"middle\">The cost-price table is not used</text>\n  <text x=\"181\" y=\"198\" font-size=\"10\" fill=\"#166534\" text-anchor=\"middle\">Attribution is right with no rows entered</text>\n\n  <rect x=\"368\" y=\"142\" width=\"318\" height=\"72\" rx=\"6\" fill=\"#fce7f3\" stroke=\"#ec4899\"/>\n  <text x=\"527\" y=\"165\" font-size=\"12\" fill=\"#9d174d\" text-anchor=\"middle\">Tokens come back, a fee does not</text>\n  <text x=\"527\" y=\"183\" font-size=\"10\" fill=\"#9d174d\" text-anchor=\"middle\">Self-hosted, some relays, local models</text>\n  <text x=\"527\" y=\"198\" font-size=\"10\" fill=\"#9d174d\" text-anchor=\"middle\">Enter Input / Output by upstream name</text>\n\n  <rect x=\"22\" y=\"242\" width=\"664\" height=\"54\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"354\" y=\"264\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">A blank is stored as 0, not as unknown</text>\n  <text x=\"354\" y=\"282\" font-size=\"10\" fill=\"#1e40af\" text-anchor=\"middle\">Use 0 only when it is free. If the price is unknown, skip the row. A false 0 hides cost.</text>\n\n  <!-- 脚注 -->\n  <text x=\"354\" y=\"326\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">Use the upstream model name, not the name you call on Tare. A mismatch rarely errors. Cost just stays empty.</text>\n  <text x=\"354\" y=\"341\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">All four prices are per million tokens. There is no effective date. Backfill uses today's price.</text>\n</svg>\n","en-cost-prices-coverage":"<svg viewBox=\"0 0 708 284\" width=\"708\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\">\n  <title>No cost price: coverage marks the other 38%</title>\n  <desc>When the upstream omits cost and no price matches, the call still works and the cost column is empty. The report shows the known amount and coverage together. The uncovered share had a cost the platform cannot see.</desc>\n  <style>\n    text { font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', system-ui, sans-serif; }\n  </style>\n\n  <!-- 浅色画布 -->\n  <rect x=\"0\" y=\"0\" width=\"708\" height=\"284\" fill=\"#ffffff\"/>\n\n  <!-- 版式算术：\n       上条横贯整行 22..686（宽 664），高 54（12px + 10px），顶边 60、底边 114。\n       下面两栏，宽 318、间距 28，于是 22..340 / 368..686，顶边 142、底边 214。\n       两栏等宽而不是按 62 : 38 取宽：同一行里的两个框尺寸差不得超过 60px，\n       按比例取宽会差 150px 以上，质检直接判「同行尺寸不齐」。\n       比例本身交给数字表达（62% / 38% 就是 12px 那一行）。\n       内容左右边界 22..686，中心 354；viewBox 宽 = 664 + 两侧各 22 = 708。\n       高度 = 脚注末行基线 259 + 下伸 2.5 + 22px 边距 = 283.5，取整 284。 -->\n\n  <text x=\"354\" y=\"34\" font-size=\"16\" fill=\"#1e293b\" text-anchor=\"middle\">No cost price: coverage marks the other 38%</text>\n\n  <rect x=\"22\" y=\"60\" width=\"664\" height=\"54\" rx=\"6\" fill=\"#dbeafe\" stroke=\"#3b82f6\"/>\n  <text x=\"354\" y=\"82\" font-size=\"12\" fill=\"#1e40af\" text-anchor=\"middle\">Known cost this month ¥1,234 · coverage 62%</text>\n  <text x=\"354\" y=\"100\" font-size=\"10\" fill=\"#1e40af\" text-anchor=\"middle\">Coverage is shown with the amount. ¥1,234 is the known part, not the whole month.</text>\n\n  <rect x=\"22\" y=\"142\" width=\"318\" height=\"72\" rx=\"6\" fill=\"#d1fae5\" stroke=\"#22c55e\"/>\n  <text x=\"181\" y=\"165\" font-size=\"12\" fill=\"#166534\" text-anchor=\"middle\">Covered 62%</text>\n  <text x=\"181\" y=\"183\" font-size=\"10\" fill=\"#166534\" text-anchor=\"middle\">The platform can price these calls</text>\n  <text x=\"181\" y=\"198\" font-size=\"10\" fill=\"#166534\" text-anchor=\"middle\">They enter Analytics, attribution, margin</text>\n\n  <rect x=\"368\" y=\"142\" width=\"318\" height=\"72\" rx=\"6\" fill=\"#fce7f3\" stroke=\"#ec4899\"/>\n  <text x=\"527\" y=\"165\" font-size=\"12\" fill=\"#9d174d\" text-anchor=\"middle\">Uncovered 38%</text>\n  <text x=\"527\" y=\"183\" font-size=\"10\" fill=\"#9d174d\" text-anchor=\"middle\">These calls had a cost the platform cannot see</text>\n  <text x=\"527\" y=\"198\" font-size=\"10\" fill=\"#9d174d\" text-anchor=\"middle\">Margin on a partial figure comes out high</text>\n\n  <!-- 脚注 -->\n  <text x=\"354\" y=\"244\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">The cost column is empty only when cost is omitted and no price matches. Calls, billing, and token counts remain.</text>\n  <text x=\"354\" y=\"259\" font-size=\"10\" fill=\"#64748b\" text-anchor=\"middle\">The channel page lists models missing a price. That list is GET /v1/providers/{id}/missing-costs.</text>\n</svg>\n"}}