Skip to main content
Glama

评估大模型调用成本

estimate_cost
Read-onlyIdempotent

估算一段文本或指定 token 数在某个大模型上的输入侧调用成本,以人民币 ¥ 计价。text_or_tokens 支持两种模式:传自然语言文本时自动估算 token 数(中文按字符、英文按词分别计),传纯数字字符串时直接作为已知 token 数使用。返回:所用估算方法、token 数、按原价计的输入成本;若该模型提供缓存输入价,另给出缓存命中成本、相对原价的节省百分比与倍数差价;末尾附该模型的输入 / 输出 / 缓存输入单价(每百万 tokens)。⚠️ 本工具只计算输入成本,不含输出 token 费用——要估算完整往返成本,需另取输出单价自行相加。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modelYes模型 ID 或模糊名称,大小写不敏感(例如 'deepseek-v4-pro'、'gpt-5'、'claude-sonnet')。匹配规则与 query_model_price 一致;不确定名称时可先调 query_model_price 确认。
time_bandNo分时模型的计费时段。缺省为 peak(峰时/最坏价,避免低估);只有确认调用发生在官方空闲时段时才传 off_peak。
text_or_tokensYes二选一:① 待估算的自然语言文本(如一段提示词或整篇文档),工具按中文字符 + 英文词估算 token 数;② 纯数字字符串表示已知 token 数,如 '200000'。注意:整串都是数字时一律按模式 ② 处理——若确实要估算一串数字本身的 token 数,请混入任意非数字字符。

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description is highly transparent about behavioral nuances: it covers only input-side costs (not output), explains the token estimation method (Chinese chars vs. English words), and details the edge case for numeric strings. It also clarifies that the output includes method, cost, and optional cache pricing details, without contradicting the annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is detailed but well-structured, using semicolons to separate distinct aspects (modes, output fields, caveats). It avoids redundancy and keeps each sentence purposeful, though it is somewhat long for a simple utility.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description is comprehensive for a cost-estimation tool: it covers input handling, estimation methodology, output fields (method, cost, cache savings, unit prices), currency, and the limitation to input costs. It also references the sibling tool for model lookup, making it self-contained in context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

While the schema already provides per-parameter descriptions, the tool description enriches them with concrete examples and clarifies ambiguous semantics (e.g., the dual meaning of text_or_tokens, the default time_band value, and the matching rule for model). This goes beyond the schema baseline, though not by a huge margin.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: estimating the input-side cost for a model given text or token count, priced in RMB. It distinguishes itself from the sibling tool 'query_model_price' by focusing on cost estimation rather than price lookup, making the purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly explains when to use this tool (to estimate cost for given text/tokens) and how to use the two input modes. It also references the sibling tool 'query_model_price' for confirming model names, and provides fallback guidance for ambiguous input (e.g., mixing non-digit characters to force text interpretation).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

TDQS

A3.9/5.0
Disambiguation5/5

The two tools have clearly distinct purposes: one estimates input-side costs for text/tokens (a calculation service), the other queries model price listings (a reference/data service). There is no overlap or ambiguity between them; the shared context of model pricing is handled without duplication.

Naming Consistency4/5

Both tools use a verb_noun pattern: 'estimate_cost' and 'query_model_price'. While the pattern is consistent (verb + object), the objects differ in abstraction—'cost' vs. 'model_price'—but this is acceptable. A minor deviation is that 'query_model_price' could be seen as a query action, while 'estimate_cost' is a computation, but the naming style remains coherent.

Tool Count3/5

With only 2 tools, the server is minimal. For a focused utility like LLM cost estimation, 2 tools might be sufficient, but it feels slightly thin because an agent might expect additional related capabilities, such as output-cost estimation or a combined estimate. However, the purpose is clearly narrowed to input-side cost and price queries, so it is borderline.

Completeness2/5

The domain is LLM cost estimation, but the tool surface is incomplete: 'estimate_cost' explicitly warns that it only handles input cost and does not include output tokens, but there is no tool to estimate full round-trip costs or to combine input/output. It lacks a tool to estimate output cost directly, and while 'query_model_price' provides output prices, the agent must manually integrate them. This is a significant gap because the core use case of estimating a complete API call cost is not fully supported.

Resources