Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(platform): clarify builder cost display for OpenRouter and free providers (#13091)

Zamil Majdy6dc836ab868b
diff --git a/autogpt_platform/backend/backend/blocks/_base.py b/autogpt_platform/backend/backend/blocks/_base.py
index ea992d4469..55a0383a7f 100644
--- a/autogpt_platform/backend/backend/blocks/_base.py
+++ b/autogpt_platform/backend/backend/blocks/_base.py
@@ -18,7 +18,7 @@ from typing import (
import jsonref
import jsonschema
-from pydantic import BaseModel
+from pydantic import BaseModel, Field
from backend.data.block import BlockInput, BlockOutput, BlockOutputEntry
from backend.data.model import (
@@ -129,6 +129,21 @@ _DYNAMIC_COST_TYPES: frozenset[BlockCostType] = frozenset(
)
+class TokenRateDisplay(BaseModel):
+ """Public per-1M-token USD rates surfaced to the builder UI.
+
+ Populated only on LLM block costs whose model has a TOKEN_COST rate.
+ cache_* fields are set only when the provider publishes a distinct
+ cached-token rate (Anthropic). Display-only — billing always uses the
+ internal credit math in `BlockCost.cost_amount`.
+ """
+
+ input_usd_per_1m: float = Field(ge=0)
+ output_usd_per_1m: float = Field(ge=0)
+ cache_read_usd_per_1m: Optional[float] = Field(default=None, ge=0)
+ cache_creation_usd_per_1m: Optional[float] = Field(default=None, ge=0)
+
+
class BlockCost(BaseModel):
cost_amount: int
cost_filter: BlockInput
@@ -140,6 +155,10 @@ class BlockCost(BaseModel):
# point-wise. Example: cost_amount=1, cost_divisor=10 under SECOND means
# "1 credit per 10 seconds of walltime".
cost_divisor: int = 1
+ # LLM-specific display rate card. None on non-LLM blocks and on LLM
+ # entries whose model isn't in TOKEN_COST yet (those render
+ # "Pay-as-you-go" / flat-tier).
+ token_rate: Optional[TokenRateDisplay] = None
def __init__(
self,
diff --git a/autogpt_platform/backend/backend/data/block_cost_config.py b/autogpt_platform/backend/backend/data/block_cost_config.py
index 54e80cf28f..7563f5047a 100644
--- a/autogpt_platform/backend/backend/data/block_cost_config.py
+++ b/autogpt_platform/backend/backend/data/block_cost_config.py
@@ -3,8 +3,9 @@ from typing import TYPE_CHECKING, Type
from pydantic import BaseModel
-from backend.blocks._base import Block, BlockCost, BlockCostType
+from backend.blocks._base import Block, BlockCost, BlockCostType, TokenRateDisplay
from backend.data.block import BlockInput
+from backend.data.model import APIKeyCredentials
if TYPE_CHECKING:
from backend.data.model import NodeExecutionStats
@@ -91,6 +92,7 @@ from backend.integrations.credentials_store import (
llama_api_credentials,
mem0_credentials,
nvidia_credentials,
+ ollama_credentials,
open_router_credentials,
openai_credentials,
replicate_credentials,
@@ -256,6 +258,9 @@ TOKEN_COST: dict[LlmModel, TokenRate] = {
LlmModel.CLAUDE_4_6_OPUS: TokenRate(
input=750, output=3750, cache_read=75, cache_creation=938
),
+ LlmModel.CLAUDE_4_7_OPUS: TokenRate(
+ input=750, output=3750, cache_read=75, cache_creation=938
+ ),
LlmModel.CLAUDE_4_5_OPUS: TokenRate(
input=750, output=3750, cache_read=75, cache_creation=938
),
@@ -397,124 +402,158 @@ def _lookup_llm_model(raw: "str | LlmModel | None") -> "LlmModel | None":
return None
+# TOKEN_COST stores credits per 1M tokens at a uniform 1.5x margin over the
+# published provider price (1 credit ≈ $0.01). Convert back to the public USD
+# rate for UI display so the builder shows real provider pricing instead of
+# the internal credit number. 150 = 100 cr/$ × 1.5x margin.
+_USD_PER_1M_DIVISOR = 150
+
+
+def _token_rate_display(model: LlmModel) -> TokenRateDisplay | None:
+ """Return the published per-1M-token USD `TokenRateDisplay` for `model`,
+ or None if the model has no TOKEN_COST entry. cache_* fields are set
+ only when the provider publishes a distinct cached-token rate (most
+ non-Anthropic providers store 0 in TOKEN_COST and surface None here).
+ """
+ rate = TOKEN_COST.get(model)
+ if rate is None:
+ return None
+ return TokenRateDisplay(
+ input_usd_per_1m=rate.input / _USD_PER_1M_DIVISOR,
+ output_usd_per_1m=rate.output / _USD_PER_1M_DIVISOR,
+ cache_read_usd_per_1m=(
+ rate.cache_read / _USD_PER_1M_DIVISOR if rate.cache_read else None
+ ),
+ cache_creation_usd_per_1m=(
+ rate.cache_creation / _USD_PER_1M_DIVISOR if rate.cache_creation else None
+ ),
+ )
+
+
+def _tokens_llm_cost(model: LlmModel, credentials: APIKeyCredentials) -> BlockCost:
+ """Build a TOKENS BlockCost for `model` + `credentials`, attaching the
+ public per-1M-token USD rates when the model has a TOKEN_COST entry.
+ """
+ return BlockCost(
+ cost_type=BlockCostType.TOKENS,
+ cost_filter={
+ "model": model,
+ "credentials": {
+ "id": credentials.id,
+ "provider": credentials.provider,
+ "type": credentials.type,
+ },
+ },
+ cost_amount=MODEL_COST[model],
+ token_rate=_token_rate_display(model),
+ )
+
+
+def _groq_llm_cost(model: LlmModel) -> BlockCost:
+ """Groq variant of `_tokens_llm_cost` — keeps the legacy id-only
+ cost_filter shape so older graphs that stored just the credential id
+ continue to match.
+ """
+ return BlockCost(
+ cost_type=BlockCostType.TOKENS,
+ cost_filter={
+ "model": model,
+ "credentials": {"id": groq_credentials.id},
+ },
+ cost_amount=MODEL_COST[model],
+ token_rate=_token_rate_display(model),
+ )
+
+
+def _open_router_llm_cost(model: LlmModel) -> BlockCost:
+ """OpenRouter variant — bills via COST_USD against x-total-cost, but
+ still exposes the same per-1M-token USD rates so the builder UI shows
+ the "$X in / $Y out per 1M tokens" pair instead of "Pay-as-you-go".
+ """
+ return BlockCost(
+ cost_type=BlockCostType.COST_USD,
+ cost_filter={
+ "model": model,
+ "credentials": {
+ "id": open_router_credentials.id,
+ "provider": open_router_credentials.provider,
+ "type": open_router_credentials.type,
+ },
+ },
+ cost_amount=150,
+ token_rate=_token_rate_display(model),
+ )
+
+
LLM_COST = (
# Anthropic Models
[
- BlockCost(
- cost_type=BlockCostType.TOKENS,
- cost_filter={
- "model": model,
- "credentials": {
- "id": anthropic_credentials.id,
- "provider": anthropic_credentials.provider,
- "type": anthropic_credentials.type,
- },
- },
- cost_amount=cost,
- )
- for model, cost in MODEL_COST.items()
+ _tokens_llm_cost(model, anthropic_credentials)
+ for model in MODEL_COST
if MODEL_METADATA[model].provider == "anthropic"
]
# OpenAI Models
+ [
- BlockCost(
- cost_type=BlockCostType.TOKENS,
- cost_filter={
- "model": model,
- "credentials": {
- "id": openai_credentials.id,
- "provider": openai_credentials.provider,
- "type": openai_credentials.type,
- },
- },
- cost_amount=cost,
- )
- for model, cost in MODEL_COST.items()
+ _tokens_llm_cost(model, openai_credentials)
+ for model in MODEL_COST
if MODEL_METADATA[model].provider == "openai"
]
- # Groq Models
+ # Groq Models (credentials filter intentionally only uses id; rate-table
+ # lookup keys on model, so omitting provider/type avoids breaking older
+ # graphs that stored just the id).
+ [
- BlockCost(
- cost_type=BlockCostType.TOKENS,
- cost_filter={
- "model": model,
- "credentials": {"id": groq_credentials.id},
- },
- cost_amount=cost,
- )
- for model, cost in MODEL_COST.items()
+ _groq_llm_cost(model)
+ for model in MODEL_COST
if MODEL_METADATA[model].provider == "groq"
]
# Open Router Models: OpenRouter returns x-total-cost on every
# response. Bill 150 cr/$ (1.5x margin) against the authoritative
# USD value instead of maintaining per-model TOKEN_COST rates —
- # provider pricing drift is handled upstream.
+ # provider pricing drift is handled upstream. We still surface
+ # input/output_usd_per_1m for display so the builder UI shows the
+ # same "$X / $Y per 1M" pair as direct-billed providers — final
+ # charge still settles against x-total-cost regardless.
+ [
- BlockCost(
- cost_type=BlockCostType.COST_USD,
- cost_filter={
- "model": model,
- "credentials": {
- "id": open_router_credentials.id,
- "provider": open_router_credentials.provider,
- "type": open_router_credentials.type,
- },
- },
- cost_amount=150,
- )
- for model in MODEL_COST.keys()
+ _open_router_llm_cost(model)
+ for model in MODEL_COST
if MODEL_METADATA[model].provider == "open_router"
]
# Llama API Models
+ [
- BlockCost(
- cost_type=BlockCostType.TOKENS,
- cost_filter={
- "model": model,
- "credentials": {
- "id": llama_api_credentials.id,
- "provider": llama_api_credentials.provider,
- "type": llama_api_credentials.type,
- },
- },
- cost_amount=cost,
- )
- for model, cost in MODEL_COST.items()
+ _tokens_llm_cost(model, llama_api_credentials)
+ for model in MODEL_COST
if MODEL_METADATA[model].provider == "llama_api"
]
# v0 by Vercel Models
+ [
- BlockCost(
- cost_type=BlockCostType.TOKENS,
- cost_filter={
- "model": model,
- "credentials": {
- "id": v0_credentials.id,
- "provider": v0_credentials.provider,
- "type": v0_credentials.type,
- },
- },
- cost_amount=cost,
- )
- for model, cost in MODEL_COST.items()
+ _tokens_llm_cost(model, v0_credentials)
+ for model in MODEL_COST
if MODEL_METADATA[model].provider == "v0"
]
# AI/ML Api Models
+ + [
+ _tokens_llm_cost(model, aiml_api_credentials)
+ for model in MODEL_COST
+ if MODEL_METADATA[model].provider == "aiml_api"
+ ]
+ # Ollama: self-hosted, no provider charge. Explicit zero-cost entry so
+ # the builder UI can render "Free" instead of an empty cost label (which
+ # the user reads as "unknown" / missing data).
+ [
BlockCost(
- cost_type=BlockCostType.TOKENS,
+ cost_type=BlockCostType.RUN,
+ cost_amount=0,
cost_filter={
"model": model,
"credentials": {
- "id": aiml_api_credentials.id,
- "provider": aiml_api_credentials.provider,
- "type": aiml_api_credentials.type,
+ "id": ollama_credentials.id,
+ "provider": ollama_credentials.provider,
+ "type": ollama_credentials.type,
},
},
- cost_amount=cost,
)
- for model, cost in MODEL_COST.items()
- if MODEL_METADATA[model].provider == "aiml_api"
+ for model in MODEL_COST
+ if MODEL_METADATA[model].provider == "ollama"
]
)
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/CustomNode/components/NodeCost.tsx b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/CustomNode/components/NodeCost.tsx
index b47bcf0540..dff87b472f 100644
--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/CustomNode/components/NodeCost.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/CustomNode/components/NodeCost.tsx
@@ -7,45 +7,99 @@ import { isCostFilterMatch } from "../../../../helper";
import { useNodeStore } from "@/app/(platform)/build/stores/nodeStore";
import { useShallow } from "zustand/react/shallow";
-type CostLabelKind = "fixed" | "per-unit" | "dynamic";
+type CostDisplay =
+ | { kind: "free" }
+ | {
+ kind: "token-rate";
+ input: number;
+ output: number;
+ cacheRead: number | null;
+ cacheCreation: number | null;
+ }
+ | { kind: "by-usd" }
+ | { kind: "fixed"; amountText: string; suffix: string; note?: string }
+ | { kind: "per-unit"; amountText: string; suffix: string; note?: string };
-interface CostLabel {
- kind: CostLabelKind;
- unitSuffix: string;
- note?: string;
+function formatUsd(value: number): string {
+ return `$${value.toFixed(2)}`;
}
-function getCostLabel(blockCost: BlockCost): CostLabel {
+function tokenRateTooltip(d: {
+ input: number;
+ output: number;
+ cacheRead: number | null;
+ cacheCreation: number | null;
+}): string {
+ const parts = [
+ `Input: ${formatUsd(d.input)} / 1M tokens`,
+ `Output: ${formatUsd(d.output)} / 1M tokens`,
+ ];
+ if (d.cacheRead != null)
+ parts.push(`Cached input: ${formatUsd(d.cacheRead)} / 1M tokens`);
+ if (d.cacheCreation != null)
+ parts.push(`Cache write: ${formatUsd(d.cacheCreation)} / 1M tokens`);
+ parts.push("Final charge scales with real usage (1.5× margin applied).");
+ return parts.join(" · ");
+}
+
+function getDisplay(
+ blockCost: BlockCost,
+ formatCredits: (n: number | null) => string,
+): CostDisplay {
+ // Token-rate pair takes precedence regardless of cost_type so that
+ // OpenRouter (COST_USD)-billed models show the same "$X / $Y per 1M"
+ // format as direct-billed providers when we have a published rate.
+ // The internal billing path (TOKENS vs COST_USD) is not user-facing.
+ if (blockCost.token_rate) {
+ return {
+ kind: "token-rate",
+ input: blockCost.token_rate.input_usd_per_1m,
+ output: blockCost.token_rate.output_usd_per_1m,
+ cacheRead: blockCost.token_rate.cache_read_usd_per_1m ?? null,
+ cacheCreation: blockCost.token_rate.cache_creation_usd_per_1m ?? null,
+ };
+ }
+
+ if (blockCost.cost_type === BlockCostType.cost_usd) {
+ return { kind: "by-usd" };
+ }
+
+ if (
+ blockCost.cost_type === BlockCostType.run &&
+ blockCost.cost_amount === 0
+ ) {
+ return { kind: "free" };
+ }
+
const divisor = blockCost.cost_divisor;
+ const amountText = formatCredits(blockCost.cost_amount);
+
switch (blockCost.cost_type) {
case BlockCostType.run:
- return { kind: "fixed", unitSuffix: "/run" };
+ return { kind: "fixed", amountText, suffix: "/run" };
case BlockCostType.byte:
- return { kind: "per-unit", unitSuffix: "/byte" };
+ return { kind: "per-unit", amountText, suffix: "/byte" };
case BlockCostType.second:
return {
kind: "per-unit",
- unitSuffix: divisor && divisor > 1 ? `/ ${divisor}s` : "/sec",
+ amountText,
+ suffix: divisor && divisor > 1 ? `/ ${divisor}s` : "/sec",
};
case BlockCostType.items:
return {
kind: "per-unit",
- unitSuffix: divisor && divisor > 1 ? `/ ${divisor} items` : "/item",
- };
- case BlockCostType.cost_usd:
- return {
- kind: "dynamic",
- unitSuffix: "· by USD",
- note: "Final charge scales with provider-reported USD spend",
+ amountText,
+ suffix: divisor && divisor > 1 ? `/ ${divisor} items` : "/item",
};
case BlockCostType.tokens:
return {
- kind: "dynamic",
- unitSuffix: "· by tokens",
- note: "Floor shown; final charge scales with real token usage (cached tokens discounted)",
+ kind: "fixed",
+ amountText,
+ suffix: "/run",
+ note: "Pre-flight flat estimate — per-token rate not in our catalog yet.",
};
default:
- return { kind: "fixed", unitSuffix: `/${blockCost.cost_type}` };
+ return { kind: "fixed", amountText, suffix: `/${blockCost.cost_type}` };
}
}
@@ -69,24 +123,56 @@ export const NodeCost = ({
if (!blockCost) return null;
- const label = getCostLabel(blockCost);
- const amountText =
- label.kind === "fixed"
- ? formatCredits(blockCost.cost_amount)
- : blockCost.cost_amount > 0
- ? `~${formatCredits(blockCost.cost_amount)}`
- : "—";
+ const display = getDisplay(blockCost, formatCredits);
+
+ if (display.kind === "free") {
+ return (
+ <div className="mr-3 flex items-center gap-1 text-base font-light">
+ <CoinIcon className="h-3 w-3" />
+ <Text variant="small" className="!font-medium">
+ Free
+ </Text>
+ </div>
+ );
+ }
+
+ if (display.kind === "token-rate") {
+ return (
+ <div
+ className="mr-3 flex items-center gap-1 text-base font-light"
+ title={tokenRateTooltip(display)}
+ >
+ <CoinIcon className="h-3 w-3" />
+ <Text variant="small" className="!font-medium">
+ {`${formatUsd(display.input)} in / ${formatUsd(display.output)} out`}
+ </Text>
+ <Text variant="small">{" per 1M tokens"}</Text>
+ </div>
+ );
+ }
+
+ if (display.kind === "by-usd") {
+ return (
+ <div
+ className="mr-3 flex items-center gap-1 text-base font-light"
+ title="Pay-as-you-go pricing. Final charge matches the provider's per-token rate plus a 1.5× margin."
+ >
+ <CoinIcon className="h-3 w-3" />
+ <Text variant="small">Pay-as-you-go</Text>
+ </div>
+ );
+ }
return (
<div
className="mr-3 flex items-center gap-1 text-base font-light"
- title={label.note}
+ title={display.note}
>
<CoinIcon className="h-3 w-3" />
<Text variant="small" className="!font-medium">
- {amountText}
+ {display.amountText}
</Text>
- <Text variant="small">{` ${label.unitSuffix}`}</Text>
+ <Text variant="small">{` ${display.suffix}`}</Text>
</div>
);
};
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/CustomNode/components/__tests__/NodeCost.test.tsx b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/CustomNode/components/__tests__/NodeCost.test.tsx
index da78dcd87e..d775c90235 100644
--- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/CustomNode/components/__tests__/NodeCost.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/CustomNode/components/__tests__/NodeCost.test.tsx
@@ -23,7 +23,9 @@ function cost(overrides: Partial<BlockCost>): BlockCost {
describe("NodeCost", () => {
beforeEach(() => {
- useNodeStore.setState({ getHardCodedValues: () => ({}) } as any);
+ useNodeStore.setState({
+ getHardCodedValues: () => ({}),
+ } as Partial<ReturnType<typeof useNodeStore.getState>>);
});
it("renders fixed /run label for RUN cost type", () => {
@@ -90,7 +92,7 @@ describe("NodeCost", () => {
expect(screen.getByText(/\/ 5 items/)).toBeTruthy();
});
- it("renders '· by USD' for COST_USD and shows approximate prefix for positive floor", () => {
+ it("renders 'Pay-as-you-go' for COST_USD without a published rate", () => {
render(
<NodeCost
blockCosts={[
@@ -99,23 +101,104 @@ describe("NodeCost", () => {
nodeId="n1"
/>,
);
- expect(screen.getByText(/~\$2\.00/)).toBeTruthy();
- expect(screen.getByText(/· by USD/)).toBeTruthy();
+ expect(screen.getByText("Pay-as-you-go")).toBeTruthy();
+ expect(screen.queryByText(/\$/)).toBeNull();
+ });
+
+ it("renders explicit in/out USD pair for COST_USD when published rate is provided", () => {
+ render(
+ <NodeCost
+ blockCosts={[
+ cost({
+ cost_type: BlockCostType.cost_usd,
+ cost_amount: 150,
+ token_rate: {
+ input_usd_per_1m: 0.3,
+ output_usd_per_1m: 1.2,
+ },
+ }),
+ ]}
+ nodeId="n1"
+ />,
+ );
+ expect(screen.getByText("$0.30 in / $1.20 out")).toBeTruthy();
+ expect(screen.getByText(/per 1M tokens/)).toBeTruthy();
+ });
+
+ it("includes cache rates in the tooltip when present", () => {
+ render(
+ <NodeCost
+ blockCosts={[
+ cost({
+ cost_type: BlockCostType.tokens,
+ cost_amount: 14,
+ token_rate: {
+ input_usd_per_1m: 5,
+ output_usd_per_1m: 25,
+ cache_read_usd_per_1m: 0.5,
+ cache_creation_usd_per_1m: 6.25,
+ },
+ }),
+ ]}
+ nodeId="n1"
+ />,
+ );
+ const tooltipHost = screen
+ .getByText("$5.00 in / $25.00 out")
+ .closest("div");
+ expect(tooltipHost?.getAttribute("title")).toMatch(/Cached input: \$0\.50/);
+ expect(tooltipHost?.getAttribute("title")).toMatch(/Cache write: \$6\.25/);
+ });
+
+ it("omits cache rate lines from the tooltip when not provided", () => {
+ render(
+ <NodeCost
+ blockCosts={[
+ cost({
+ cost_type: BlockCostType.tokens,
+ cost_amount: 14,
+ token_rate: {
+ input_usd_per_1m: 5,
+ output_usd_per_1m: 25,
+ cache_read_usd_per_1m: null,
+ cache_creation_usd_per_1m: null,
+ },
+ }),
+ ]}
+ nodeId="n1"
+ />,
+ );
+ const tooltipHost = screen
+ .getByText("$5.00 in / $25.00 out")
+ .closest("div");
+ const title = tooltipHost?.getAttribute("title") ?? "";
+ expect(title).not.toMatch(/Cached input/);
+ expect(title).not.toMatch(/Cache write/);
+ expect(title).toMatch(/Input: \$5\.00/);
+ expect(title).toMatch(/Output: \$25\.00/);
});
- it("renders em-dash when dynamic cost has zero floor", () => {
+ it("renders explicit in/out USD pair for TOKENS with published rates", () => {
render(
<NodeCost
blockCosts={[
- cost({ cost_type: BlockCostType.cost_usd, cost_amount: 0 }),
+ cost({
+ cost_type: BlockCostType.tokens,
+ cost_amount: 14,
+ token_rate: {
+ input_usd_per_1m: 5,
+ output_usd_per_1m: 25,
+ },
+ }),
]}
nodeId="n1"
/>,
);
- expect(screen.getByText("—")).toBeTruthy();
+ expect(screen.getByText("$5.00 in / $25.00 out")).toBeTruthy();
+ expect(screen.getByText(/per 1M tokens/)).toBeTruthy();
});
- it("renders '· by tokens' with floor hint for TOKENS", () => {
+ it("falls back to flat /run for TOKENS without published rates", () => {
render(
<NodeCost
blockCosts={[
@@ -124,8 +207,19 @@ describe("NodeCost", () => {
nodeId="n1"
/>,
);
- expect(screen.getByText(/~\$1\.50/)).toBeTruthy();
- expect(screen.getByText(/· by tokens/)).toBeTruthy();
+ expect(screen.getByText("$1.50")).toBeTruthy();
+ expect(screen.getByText(/\/run/)).toBeTruthy();
+ });
+
+ it("renders 'Free' for RUN cost type with zero amount", () => {
+ render(
+ <NodeCost
+ blockCosts={[cost({ cost_type: BlockCostType.run, cost_amount: 0 })]}
+ nodeId="n1"
+ />,
+ );
+ expect(screen.getByText("Free")).toBeTruthy();
+ expect(screen.queryByText(/\$/)).toBeNull();
});
it("renders /byte suffix for BYTE cost type", () => {
@@ -157,7 +251,7 @@ describe("NodeCost", () => {
it("returns null when no matching blockCost found", () => {
useNodeStore.setState({
getHardCodedValues: () => ({ provider: "openai" }),
- } as any);
+ } as Partial<ReturnType<typeof useNodeStore.getState>>);
const { container } = render(
<NodeCost
blockCosts={[
diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.json
index 668693a828..e324b6be73 100644
--- a/autogpt_platform/frontend/src/app/api/openapi.json
+++ b/autogpt_platform/frontend/src/app/api/openapi.json
@@ -10282,6 +10282,12 @@
"type": "integer",
"title": "Cost Divisor",
"default": 1
+ },
+ "token_rate": {
+ "anyOf": [
+ { "$ref": "#/components/schemas/TokenRateDisplay" },
+ { "type": "null" }
+ ]
}
},
"type": "object",
@@ -17812,6 +17818,32 @@
"title": "TokenIntrospectionResult",
"description": "Result of token introspection (RFC 7662)"
},
+ "TokenRateDisplay": {
+ "properties": {
+ "input_usd_per_1m": {
+ "type": "number",
+ "minimum": 0.0,
+ "title": "Input Usd Per 1M"
+ },
+ "output_usd_per_1m": {
+ "type": "number",
+ "minimum": 0.0,
+ "title": "Output Usd Per 1M"
+ },
+ "cache_read_usd_per_1m": {
+ "anyOf": [{ "type": "number", "minimum": 0.0 }, { "type": "null" }],
+ "title": "Cache Read Usd Per 1M"
+ },
+ "cache_creation_usd_per_1m": {
+ "anyOf": [{ "type": "number", "minimum": 0.0 }, { "type": "null" }],
+ "title": "Cache Creation Usd Per 1M"
+ }
+ },
+ "type": "object",
+ "required": ["input_usd_per_1m", "output_usd_per_1m"],
+ "title": "TokenRateDisplay",
+ "description": "Public per-1M-token USD rates surfaced to the builder UI.\n\nPopulated only on LLM block costs whose model has a TOKEN_COST rate.\ncache_* fields are set only when the provider publishes a distinct\ncached-token rate (Anthropic). Display-only — billing always uses the\ninternal credit math in `BlockCost.cost_amount`."
+ },
"TokenRequestByCode": {
"properties": {
"grant_type": {