Skip to content

feat: add cost_per_request flat-fee pricing field across DB, cost engine, overrides, and docs - #6079

Merged
akshaydeo merged 2 commits into
devfrom
08-12-feat_add_cost_per_request_flat_per-request_pricing_field
Aug 11, 2026
Merged

feat: add cost_per_request flat-fee pricing field across DB, cost engine, overrides, and docs#6079
akshaydeo merged 2 commits into
devfrom
08-12-feat_add_cost_per_request_flat_per-request_pricing_field

Conversation

@Pratham-Mishra04

Copy link
Copy Markdown
Collaborator

Summary

Adds support for a cost_per_request flat fee field in the pricing system. This allows a fixed surcharge to be billed once per request, additive on top of any existing usage-based costs (tokens, audio seconds, images, etc.), regardless of request type.

Changes

  • Added CostPerRequest field to TableModelPricing, Options, and PricingEntry types, with full conversion between them
  • Added a database migration (add_cost_per_request_pricing_column) to introduce the new column
  • Updated computeCostFromInput to apply the flat per-request fee after computing usage-based cost for all supported request types
  • Included cost_per_request in the pricing sync update columns and the patchPricing override path
  • Exposed cost_per_request in the model info pricing output (pricing.Request)
  • Added cost_per_request to the OpenAPI schema and governance YAML with a minimum: 0 constraint
  • Added the field to the custom pricing override UI, available across chat, embedding, rerank, audio, image, video, and OCR request type groups
  • Added cost_per_request to the PricingOverridePatch TypeScript interface
  • Updated the model catalog architecture docs and custom pricing provider docs to document the new field
  • Added unit tests covering flat fee billing (TestCalculateCost_ChatCompletion_CostPerRequest) and override patching (TestPatchPricing_CostPerRequest)

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

# Core/Transports
go version
go test ./...

# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build

Set cost_per_request on a custom pricing override for any model and verify that the billed cost equals the usage-based cost plus the flat fee. For example, with input_cost_per_token=0.000005, output_cost_per_token=0.000015, and cost_per_request=0.01, a request with 10,000 prompt tokens and 2,000 completion tokens should produce a total cost of $0.09.

Screenshots/Recordings

The "Flat fee / request" field will appear in the custom pricing override sheet for chat, embedding, rerank, audio, image, video, and OCR request types.

Breaking changes

  • No

Related issues

Security considerations

No auth, secrets, or PII implications. The new field is a non-negative float and is validated with minimum: 0 in the schema.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added support for configuring a flat fee per billed request.
    • Per-request fees can be combined with usage-based pricing across supported request types.
    • Added per-request pricing overrides in the management interface, including setting the fee to zero.
  • Bug Fixes

    • Pricing calculations now include the configured per-request fee exactly once per billed request.
  • Documentation

    • Updated pricing documentation and API schemas to describe the field and its non-negative value requirement.

Walkthrough

The change adds optional cost_per_request pricing. It updates pricing schemas, config-store persistence, overrides, request-cost calculation, model information, UI controls, and documentation.

Changes

Per-request pricing

Layer / File(s) Summary
Pricing contract and persistence
docs/architecture/framework/model-catalog.mdx, docs/openapi/..., framework/configstore/..., framework/modelcatalog/datasheet/types.go
Pricing schemas and config-store records now support an optional non-negative cost_per_request value. Migrations add and remove the database column.
Pricing propagation and billing
framework/modelcatalog/datasheet/{overrides.go,overrides_test.go,cost.go,cost_test.go}, framework/modelcatalog/modelinfo.go
Overrides and pricing conversions propagate the value. Request-cost calculation adds the flat fee once to supported request costs.
Pricing interface and documentation
ui/app/workspace/custom-pricing/overrides/pricingOverrideSheet.tsx, ui/lib/types/governance.ts, docs/providers/custom-pricing.mdx
The UI and governance types expose the flat fee for supported request types. Provider documentation describes its behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PricingOverride
  participant TableModelPricing
  participant computeCostFromInput
  participant ApplyModelInfo
  PricingOverride->>TableModelPricing: persist CostPerRequest
  TableModelPricing->>computeCostFromInput: provide resolved pricing
  computeCostFromInput->>computeCostFromInput: add CostPerRequest once
  computeCostFromInput->>ApplyModelInfo: return combined request cost
Loading

Possibly related PRs

Suggested reviewers: akshaydeo, danpiths, tejasghatte

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely summarizes the primary feature and its affected areas.
Description check ✅ Passed The description covers the summary, changes, testing, affected areas, breaking changes, security, and documentation, but leaves checklist items and related issues incomplete.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 08-12-feat_add_cost_per_request_flat_per-request_pricing_field

Comment @coderabbitai help to get the list of available commands.

@coderabbitai
coderabbitai Bot requested a review from TejasGhatte August 11, 2026 20:38
…ng SSO login app credentials to be reused for providers like Microsoft Entra ID that require it

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/openapi/schemas/management/governance.yaml`:
- Around line 1914-1917: Update the parent PricingPatch description to state
that every non-null override is applied, including zero, and distinguish
usage-based costs charged per unit from the USD flat fee charged per billed
request. Keep the existing child property definitions unchanged and align the
wording with patchPricing’s runtime behavior.

In `@docs/providers/custom-pricing.mdx`:
- Line 404: Update the cost_per_request documentation row and the related
general override rule to state that zero is a valid value and that a non-nil
zero override is applied, including whether it clears an inherited fee. Keep the
documented non-negative constraint consistent with the override behavior in the
relevant datasheet override flow.

In `@framework/modelcatalog/datasheet/overrides_test.go`:
- Around line 447-460: Extend TestPatchPricing_CostPerRequest with a zero-value
override case using a non-zero base CostPerRequest and Options{CostPerRequest:
bifrost.Ptr(0)}. Assert the patched pointer is non-nil and its value is zero,
confirming patchPricing applies zero rather than treating it as absent.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9c780e76-39d3-473d-85b0-fec7c10fa90a

📥 Commits

Reviewing files that changed from the base of the PR and between 0715840 and 5419f74.

📒 Files selected for processing (15)
  • docs/architecture/framework/model-catalog.mdx
  • docs/openapi/openapi.json
  • docs/openapi/schemas/management/governance.yaml
  • docs/providers/custom-pricing.mdx
  • framework/configstore/migrations.go
  • framework/configstore/rdb.go
  • framework/configstore/tables/modelpricing.go
  • framework/modelcatalog/datasheet/cost.go
  • framework/modelcatalog/datasheet/cost_test.go
  • framework/modelcatalog/datasheet/overrides.go
  • framework/modelcatalog/datasheet/overrides_test.go
  • framework/modelcatalog/datasheet/types.go
  • framework/modelcatalog/modelinfo.go
  • ui/app/workspace/custom-pricing/overrides/pricingOverrideSheet.tsx
  • ui/lib/types/governance.ts

Comment thread docs/openapi/schemas/management/governance.yaml
Comment thread docs/providers/custom-pricing.mdx
Comment thread framework/modelcatalog/datasheet/overrides_test.go
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 08-12-feat_add_cost_per_request_flat_per-request_pricing_field branch from 5419f74 to 8db6688 Compare August 11, 2026 20:46
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 08-12-feat_add_use_idp_credentials_option_to_token-exchange_config_allowing_sso_login_app_credentials_to_be_reused_for_providers_like_microsoft_entra_id_that_require_it branch from 0715840 to 299dd24 Compare August 11, 2026 20:46
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 08-12-feat_add_cost_per_request_flat_per-request_pricing_field branch from 8db6688 to 09347f7 Compare August 11, 2026 21:29
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 11, 2026

akshaydeo commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Merge activity

  • Aug 11, 10:06 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Aug 11, 10:07 PM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo
akshaydeo changed the base branch from 08-12-feat_add_use_idp_credentials_option_to_token-exchange_config_allowing_sso_login_app_credentials_to_be_reused_for_providers_like_microsoft_entra_id_that_require_it to graphite-base/6079 August 11, 2026 22:07
@akshaydeo
akshaydeo changed the base branch from graphite-base/6079 to dev August 11, 2026 22:07
@akshaydeo
akshaydeo dismissed coderabbitai[bot]’s stale review August 11, 2026 22:07

The base branch was changed.

@akshaydeo
akshaydeo merged commit 7ab3436 into dev Aug 11, 2026
8 of 9 checks passed
@akshaydeo
akshaydeo deleted the 08-12-feat_add_cost_per_request_flat_per-request_pricing_field branch August 11, 2026 22:07
akshaydeo pushed a commit that referenced this pull request Aug 13, 2026
…ngine, overrides, and docs (#6079)

## Summary

Adds support for a `cost_per_request` flat fee field in the pricing system. This allows a fixed surcharge to be billed once per request, additive on top of any existing usage-based costs (tokens, audio seconds, images, etc.), regardless of request type.

## Changes

- Added `CostPerRequest` field to `TableModelPricing`, `Options`, and `PricingEntry` types, with full conversion between them
- Added a database migration (`add_cost_per_request_pricing_column`) to introduce the new column
- Updated `computeCostFromInput` to apply the flat per-request fee after computing usage-based cost for all supported request types
- Included `cost_per_request` in the pricing sync update columns and the `patchPricing` override path
- Exposed `cost_per_request` in the model info pricing output (`pricing.Request`)
- Added `cost_per_request` to the OpenAPI schema and governance YAML with a `minimum: 0` constraint
- Added the field to the custom pricing override UI, available across chat, embedding, rerank, audio, image, video, and OCR request type groups
- Added `cost_per_request` to the `PricingOverridePatch` TypeScript interface
- Updated the model catalog architecture docs and custom pricing provider docs to document the new field
- Added unit tests covering flat fee billing (`TestCalculateCost_ChatCompletion_CostPerRequest`) and override patching (`TestPatchPricing_CostPerRequest`)

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [x] Docs

## How to test

```sh
# Core/Transports
go version
go test ./...

# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

Set `cost_per_request` on a custom pricing override for any model and verify that the billed cost equals the usage-based cost plus the flat fee. For example, with `input_cost_per_token=0.000005`, `output_cost_per_token=0.000015`, and `cost_per_request=0.01`, a request with 10,000 prompt tokens and 2,000 completion tokens should produce a total cost of `$0.09`.

## Screenshots/Recordings

The "Flat fee / request" field will appear in the custom pricing override sheet for chat, embedding, rerank, audio, image, video, and OCR request types.

## Breaking changes

- [x] No

## Related issues

## Security considerations

No auth, secrets, or PII implications. The new field is a non-negative float and is validated with `minimum: 0` in the schema.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
akshaydeo pushed a commit that referenced this pull request Aug 13, 2026
…ngine, overrides, and docs (#6079)

## Summary

Adds support for a `cost_per_request` flat fee field in the pricing system. This allows a fixed surcharge to be billed once per request, additive on top of any existing usage-based costs (tokens, audio seconds, images, etc.), regardless of request type.

## Changes

- Added `CostPerRequest` field to `TableModelPricing`, `Options`, and `PricingEntry` types, with full conversion between them
- Added a database migration (`add_cost_per_request_pricing_column`) to introduce the new column
- Updated `computeCostFromInput` to apply the flat per-request fee after computing usage-based cost for all supported request types
- Included `cost_per_request` in the pricing sync update columns and the `patchPricing` override path
- Exposed `cost_per_request` in the model info pricing output (`pricing.Request`)
- Added `cost_per_request` to the OpenAPI schema and governance YAML with a `minimum: 0` constraint
- Added the field to the custom pricing override UI, available across chat, embedding, rerank, audio, image, video, and OCR request type groups
- Added `cost_per_request` to the `PricingOverridePatch` TypeScript interface
- Updated the model catalog architecture docs and custom pricing provider docs to document the new field
- Added unit tests covering flat fee billing (`TestCalculateCost_ChatCompletion_CostPerRequest`) and override patching (`TestPatchPricing_CostPerRequest`)

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [x] Docs

## How to test

```sh
# Core/Transports
go version
go test ./...

# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

Set `cost_per_request` on a custom pricing override for any model and verify that the billed cost equals the usage-based cost plus the flat fee. For example, with `input_cost_per_token=0.000005`, `output_cost_per_token=0.000015`, and `cost_per_request=0.01`, a request with 10,000 prompt tokens and 2,000 completion tokens should produce a total cost of `$0.09`.

## Screenshots/Recordings

The "Flat fee / request" field will appear in the custom pricing override sheet for chat, embedding, rerank, audio, image, video, and OCR request types.

## Breaking changes

- [x] No

## Related issues

## Security considerations

No auth, secrets, or PII implications. The new field is a non-negative float and is validated with `minimum: 0` in the schema.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
@akshaydeo akshaydeo mentioned this pull request Aug 13, 2026
akshaydeo added a commit that referenced this pull request Aug 13, 2026
## ✨ Features

- **MCP Per-User OAuth** - MCP clients can hold per-user OAuth
credentials and per-user headers, configurable from `config.json` as
well as the UI, with a documented shared vs per-identity token lookup
contract and VK/Users filters on the OAuth Grants and MCP Auth Sessions
sidebars
- **Token Exchange IDP Credentials** - New `use_idp_credentials` on
`token_exchange` reuses SSO login app credentials for providers that
require it, such as Microsoft Entra ID; `client_id` becomes optional
when it is set (#6068, #6069)
- **Bedrock VPC Endpoints** - AWS Bedrock keys can target VPC endpoints
(#6064)
- **Per-Request Flat-Fee Pricing** - New `cost_per_request` field flows
through datasheet sync, the cost engine, custom overrides and the UI
override form (#6079)
- **Pricing Overrides in the Model Catalog** - `/api/models/details`
exposes resolved pricing overrides, and catalog rows resolve overrides
server-side (#6055, #6056)
- **MCP Tool Discovery Persistence** - Discovered MCP tools persist and
resync uniformly across all client types through a hash-gated core
callback, surviving restarts and propagating across a cluster
- **W3C Trace ID Propagation** - Requests carry a W3C trace ID on the
context (#5945)
- **Cancellable Log Cost Recalculation** - Log cost recalculation tasks
can be cancelled from the backend (#5801)
- **Separate OTEL Metrics Pipeline** - The OTEL collector supports a
metrics tab independent of traces, plus separate headers for traces and
metrics (#5939, #5940)
- **Roots-Only Log Filter** - New `roots_only` filter collapses fallback
chains into their root entry with child aggregates (#5737)
- **MCP Log Redaction and Plugin Logs** - MCP tool logs carry redaction
mappings and plugin logs (#5744, #5746)
- **User Agent and App Attribution in Logs** - Logs and MCP tool logs
record user agent, app, source, decision, app key and device ID
- **S3 Log Export Metadata** - Additional metadata is written alongside
S3 log exports (#6070)
- **Matview Maintenance Off Switch** - `matview_refresh_interval`
accepts `"off"` to disable logstore matview maintenance entirely (thanks
[@jeremym-tanium](https://github.com/jeremym-tanium)!) (#5693)
- **Video Request Info in Logs UI** - Video requests surface their
details in the logs UI (#5946)
- **Shell Rewriter Hook** - The UI handler exposes a `ShellRewriter`
hook for pre-hydration HTML rewriting (#5807)
- **Auth Skip Path** - Adds a context path letting trusted internal
callers bypass auth resolution

## 🐞 Fixed

- **Path Normalization Auth Bypass** - Fixed a path normalization flaw
that allowed auth to be bypassed (#5763)
- **Minimal Reasoning Effort on GPT-5 Models** - `reasoning_effort:
"minimal"` is preserved for GPT-5-family OpenAI models instead of being
downgraded to `low` (thanks [@jitokim](https://github.com/jitokim)!)
(#6046)
- **Gemini Truncated Response Finish Reason** - Truncated Gemini
responses report `MAX_TOKENS` instead of `OTHER` (thanks
[@AdityaPainuli](https://github.com/AdityaPainuli)!) (#5979)
- **Null Tool-Call Function Name on Streaming** - Streaming continuation
deltas no longer materialize an absent tool-call function name as `null`
(thanks [@AdityaPainuli](https://github.com/AdityaPainuli)!) (#5966)
- **Bedrock Document Uploads** - Fixed Bedrock file handling in
inference so office and PDF documents sent as OpenAI `type: "file"` are
accepted (#5947)
- **xAI Usage Cost** - Fixed USD cost ticks for xAI usage (#5950)
- **Anthropic Encrypted Reasoning** - Added an Anthropic error branch
when stripping encrypted reasoning content
- **MCP Reconnect and Lock Ordering** - Broke a lock-order inversion in
`ConnectionCheckerManager`, rebuilt ephemeral clients across the whole
connect+init retry, preserved last-known tool maps across close-first
reconnects, bound connect attempts to entry identity, deduped background
reconnects and gated SSE `OnConnectionLost` on connection identity
- **MCP OAuth Session Correctness** - Restricted `Reauthorize` to shared
OAuth clients, rejected inactive tokens in `ValidateToken`, made the
OAuth flow claim atomic against concurrent reauth, stopped dropping
stored scopes on decode failure, and closed a verify-headers
double-submit race that also dropped TLS, timeout and per-user-header
fields
- **Session Stickiness Reconciliation** - `needs_session_stickiness` is
pinned across `config.json` reconciliation, so an unrelated file edit
can no longer silently revert a client to per-call
- **Credential Cache Cancellation** - `headerCredentialCache.Fill` and
`userTokenCache.Fill` propagate context so a cancelled request unblocks
instead of waiting on an unrelated leader; LRU entries carry a version
so a rejected stale `Get` cannot evict a concurrently-updated value
- **Governance List-Models Call** - Budgets and rate limits no longer
trigger a list-models call (#6051)
- **Realtime Response Create Input** - Guarded `response.create` input
(#6050)
- **HTTP Server Timeouts** - Configured bounded `http.Server` timeouts
and a request-body limit
- **MCP Client State Badges** - State badges render with spaces instead
of underscores, and the state filter bucket was renamed from
`disconnected` to `unstable`
- **Entra OBO Scope** - `offline_access` is combined with
`<audience>/.default` for Entra OBO instead of replacing it (#6078)

## 🔧 Maintenance

- **Governance Route Families** - Editions can override governance route
families (#5839)
- **Dependency Upgrades** - Dependabot updates across all modules, plus
module path fixes (#6040, #5864)
- **Documentation** - config.schema.json doc fixes and Datadog env var
reference fixes in the helm chart docs (#5938, #6019)

## 🗄️ Database Migrations

**configstore:**

- **add_mcp_client_pending_oauth_config_json_column** - Adds
`pending_oauth_config_json` to `config_mcp_clients`. Reversible: drops
the added column.
- **merge_oauth_token_tables** - Consolidates `oauth_tokens` and
`oauth_user_tokens` into `mcp_oauth_tokens`. **Non-reversible**:
rollback deliberately leaves `mcp_oauth_tokens` in place, because every
OAuth read and write targets it from this migration onward and dropping
it would destroy any token created or refreshed since, forcing every
holder to re-authorize.
- **create_mcp_oauth_flows_table** - Creates `mcp_oauth_flows` to track
in-flight OAuth flows. Reversible: drops the new table.
- **drop_oauth_config_pkce_columns** - Drops CSRF state, PKCE verifier
and `expires_at` from the OAuth config table now that they live on
`mcp_oauth_flows`. **Non-reversible**: forward-only, the dropped values
were per-flow ephemeral and re-adding empty columns would restore
nothing.
- **drop_oauth_config_token_id_column** - Drops `token_id`.
**Non-reversible**: forward-only, it was a pure FK shortcut now
reachable via `(oauth_config_id, auth_mode)`.
- **add_mcp_admin_auth_mode_indexes** - Adds admin partial unique
indexes on `mcp_oauth_tokens` and `mcp_per_user_header_credentials`.
Reversible: drops both indexes.
- **add_mcp_client_token_exchange_json_column** - Adds
`token_exchange_json` to `config_mcp_clients`. Reversible: drops the
added column.
- **add_needs_session_stickiness_column** - Adds
`needs_session_stickiness` to `config_mcp_clients`. Reversible: drops
the added column.
- **add_bedrock_endpoints_columns** - Adds Bedrock VPC endpoint columns
to the keys table. Reversible: drops the added columns.
- **add_cost_per_request_pricing_column** - Adds `cost_per_request` to
model pricing. Reversible: drops the added column.

**logstore:**

- **logs_add_guardrail_debug_column** - Adds `guardrail_debug` to logs.
Reversible: drops the added column.
- **mcp_tool_logs_add_redaction_mapping_column** - Adds the redaction
mapping column to MCP tool logs. **Non-reversible**: rollback is a no-op
because dropping the column would permanently destroy reveal data for
already-redacted MCP logs.
- **logs_add_user_agent_column** - Adds user agent and app columns,
their indexes, and a `UserAgentMapping` table. Reversible: drops the
indexes and the mapping table.
- **mcp_tool_logs_add_user_agent_column** - Adds user agent and app
columns plus indexes to MCP tool logs. Reversible: drops both indexes
and the `app` column.
- **mcp_tool_logs_add_endpoint_columns** - Adds `source`, `decision`,
`app_key` and `device_id` to MCP tool logs. Reversible: drops all four
columns.
- **mcp_tool_logs_add_plugin_logs_column** - Adds `plugin_logs` to MCP
tool logs. Reversible: drops the added column.
- **logs_recreate_matviews_with_user_agent_column** and
**logs_recreate_matviews_with_app_column** - Recreate the log
materialized views to include the new columns. Rollback is a no-op
because `ensureMatViews` recreates them on next startup.

<Warning>
**High-throughput deployments: run the logstore migrations during a
low-activity window.**

Every logstore migration above alters `logs` or `mcp_tool_logs`, the two
highest-insert tables in Bifrost, and several also build indexes on
them. On a busy instance the index builds hold locks that block
concurrent log inserts for the duration of the build, and the matview
recreations rebuild against the full table. Schedule the upgrade for a
low-traffic period, or expect elevated log-write latency and possible
request-path backpressure while the migrations run.
</Warning>

<Warning>
`merge_oauth_token_tables`, `drop_oauth_config_pkce_columns` and
`drop_oauth_config_token_id_column` transform or remove existing OAuth
state and cannot be rolled back. Take a database backup before
upgrading, and do not roll the binary back past this release once the
migration has run.
</Warning>

## 🐙 Closed GitHub Issues

- [#123](#123) - Files API
Support
- [#5472](#5472) - [Bug]:
Bedrock rejects office/PDF document uploads via OpenAI `type:"file"` -
"The PDF specified was not valid"
- [#5900](#5900) - [Bug]:
Streaming continuation chunks materialize omitted tool-call metadata as
null
- [#5978](#5978) - [Bug]:
Gemini egress reports truncated responses as FinishReason OTHER,
IncompleteDetails switch matches a string that never occurs
- [#6044](#6044) - [Bug]:
normalizeOpenAIReasoningEffort maps 'minimal' to 'low' for ALL OpenAI
models, even ones that natively support 'minimal'
akshaydeo pushed a commit that referenced this pull request Aug 14, 2026
…ngine, overrides, and docs (#6079)

## Summary

Adds support for a `cost_per_request` flat fee field in the pricing system. This allows a fixed surcharge to be billed once per request, additive on top of any existing usage-based costs (tokens, audio seconds, images, etc.), regardless of request type.

## Changes

- Added `CostPerRequest` field to `TableModelPricing`, `Options`, and `PricingEntry` types, with full conversion between them
- Added a database migration (`add_cost_per_request_pricing_column`) to introduce the new column
- Updated `computeCostFromInput` to apply the flat per-request fee after computing usage-based cost for all supported request types
- Included `cost_per_request` in the pricing sync update columns and the `patchPricing` override path
- Exposed `cost_per_request` in the model info pricing output (`pricing.Request`)
- Added `cost_per_request` to the OpenAPI schema and governance YAML with a `minimum: 0` constraint
- Added the field to the custom pricing override UI, available across chat, embedding, rerank, audio, image, video, and OCR request type groups
- Added `cost_per_request` to the `PricingOverridePatch` TypeScript interface
- Updated the model catalog architecture docs and custom pricing provider docs to document the new field
- Added unit tests covering flat fee billing (`TestCalculateCost_ChatCompletion_CostPerRequest`) and override patching (`TestPatchPricing_CostPerRequest`)

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [x] Docs

## How to test

```sh
# Core/Transports
go version
go test ./...

# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

Set `cost_per_request` on a custom pricing override for any model and verify that the billed cost equals the usage-based cost plus the flat fee. For example, with `input_cost_per_token=0.000005`, `output_cost_per_token=0.000015`, and `cost_per_request=0.01`, a request with 10,000 prompt tokens and 2,000 completion tokens should produce a total cost of `$0.09`.

## Screenshots/Recordings

The "Flat fee / request" field will appear in the custom pricing override sheet for chat, embedding, rerank, audio, image, video, and OCR request types.

## Breaking changes

- [x] No

## Related issues

## Security considerations

No auth, secrets, or PII implications. The new field is a non-negative float and is validated with `minimum: 0` in the schema.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
akshaydeo pushed a commit that referenced this pull request Aug 19, 2026
…ngine, overrides, and docs (#6079)

## Summary

Adds support for a `cost_per_request` flat fee field in the pricing system. This allows a fixed surcharge to be billed once per request, additive on top of any existing usage-based costs (tokens, audio seconds, images, etc.), regardless of request type.

## Changes

- Added `CostPerRequest` field to `TableModelPricing`, `Options`, and `PricingEntry` types, with full conversion between them
- Added a database migration (`add_cost_per_request_pricing_column`) to introduce the new column
- Updated `computeCostFromInput` to apply the flat per-request fee after computing usage-based cost for all supported request types
- Included `cost_per_request` in the pricing sync update columns and the `patchPricing` override path
- Exposed `cost_per_request` in the model info pricing output (`pricing.Request`)
- Added `cost_per_request` to the OpenAPI schema and governance YAML with a `minimum: 0` constraint
- Added the field to the custom pricing override UI, available across chat, embedding, rerank, audio, image, video, and OCR request type groups
- Added `cost_per_request` to the `PricingOverridePatch` TypeScript interface
- Updated the model catalog architecture docs and custom pricing provider docs to document the new field
- Added unit tests covering flat fee billing (`TestCalculateCost_ChatCompletion_CostPerRequest`) and override patching (`TestPatchPricing_CostPerRequest`)

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [x] Docs

## How to test

```sh
# Core/Transports
go version
go test ./...

# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

Set `cost_per_request` on a custom pricing override for any model and verify that the billed cost equals the usage-based cost plus the flat fee. For example, with `input_cost_per_token=0.000005`, `output_cost_per_token=0.000015`, and `cost_per_request=0.01`, a request with 10,000 prompt tokens and 2,000 completion tokens should produce a total cost of `$0.09`.

## Screenshots/Recordings

The "Flat fee / request" field will appear in the custom pricing override sheet for chat, embedding, rerank, audio, image, video, and OCR request types.

## Breaking changes

- [x] No

## Related issues

## Security considerations

No auth, secrets, or PII implications. The new field is a non-negative float and is validated with `minimum: 0` in the schema.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
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.

3 participants