Skip to content

feat: add customizable pricing for native tools#117

Merged
chenyme merged 1 commit into
devfrom
tools_price
Jun 3, 2026
Merged

feat: add customizable pricing for native tools#117
chenyme merged 1 commit into
devfrom
tools_price

Conversation

@chenyme

@chenyme chenyme commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

优化官方原生工具计费配置能力。

本次变更将所有官方原生工具统一为按次计费配置:管理员可以为每个原生工具单独设置 $xx / 次 价格,填 0 表示不生成单独工具账单项。后端统一归一化原生工具价格配置为 unit: "call",并只在上游返回可解析的工具调用次数时生成原生工具账单明细,避免仅因模型开启工具就产生误扣费。

Change type

  • Bug fix
  • Feature
  • Documentation
  • Refactor
  • Configuration / deployment
  • Security hardening
  • Other

Affected areas

  • Frontend / UI
  • Backend / API
  • Authentication / authorization
  • Conversations / streaming
  • Files / RAG / extraction
  • Model routing / providers
  • MCP / tools
  • Billing / payments
  • Admin console
  • Deployment / Docker / configuration
  • Documentation

Verification

  • cd backend && go test ./internal/application/billing ./internal/shared/nativetool ./internal/infra/llm

Screenshots, API examples, or logs

No screenshots attached.

Billing behavior:

  • All official native tools display editable $xx / 次 pricing.
  • 0 / 次 means no separate native tool billing item.
  • Positive price is billed per upstream-reported native tool call.
  • Tools without upstream-reported call counts do not generate separate native tool billing items.

Configuration, migration, and compatibility notes

  • Native tool pricing is normalized to:
    • unit: "call"
    • priceLabel: ""
    • billable: priceNanousd > 0
  • Existing saved native tool pricing configs are normalized on read/write.
  • Default non-billable tools remain 0 / 次 unless an administrator sets a positive price.

Documentation

  • Documentation is not needed for this change.
  • Documentation was updated.
  • Documentation still needs to be updated.

Security and privacy

  • No secrets, tokens, credentials, local config, or personal data are included.
  • User data access remains scoped by authenticated user context unless an admin-only path explicitly requires broader access.
  • Security-sensitive behavior was reviewed, including billing and native tool usage accounting.

Checklist

  • I searched existing issues and pull requests.
  • Changes are focused and do not include unrelated refactors.
  • Tests or static verification were run where practical.
  • User-facing behavior, deployment steps, API contracts, or configuration changes are documented.
  • Generated artifacts are included only when this project explicitly requires them.
  • Caches, build output, .pyc files, .env files, and local storage data are not committed.

@chenyme chenyme linked an issue Jun 3, 2026 that may be closed by this pull request
3 tasks
@chenyme
chenyme merged commit 57985a1 into dev Jun 3, 2026
4 checks passed
@chenyme
chenyme deleted the tools_price branch June 3, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: 支持为官方工具配置自定义价格

1 participant