Files
ai/object/fee.go
zeekay 81ef134e90 pricing: a resold model bills at its vendor's price plus the vendor's fee
A model resold from OpenRouter billed at OpenRouter's price times
OPENROUTER_MARGIN, 1.2 unless set. Hanzo's margin belongs to its own
models, whose catalogs price them. A resold model passes through at the
vendor's price plus the fee the vendor charges on the credit it sells,
5.5% for OpenRouter today.

The fee is the host's to set: SetFees installs where a vendor's fee is
read, and cloud reads it from the usage policy a SuperAdmin edits at
admin.hanzo.ai. ai keeps no fee of its own. With none set a resold model
bills at its vendor's price; a fee that is not a percent of 0 or more
fails the catalog's refresh, which keeps the prices it had.

/v1/models lists the passthrough rates. The listing's store and events
record the vendor's own prices, unchanged.

Claude-Session: https://claude.ai/code/session_01SCPMGSQsLNF2YtHFL4bwyp
2026-10-09 02:47:33 -07:00

41 lines
1.3 KiB
Go

// Copyright 2026 Hanzo AI Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package object
import "sync/atomic"
// fees reads a vendor's fee: the percent a model resold from that vendor bills over
// the price the vendor states ("5.5"), as the host's operator sets it.
var fees atomic.Pointer[func(vendor string) string]
// SetFees installs where a vendor's fee is read (nil clears it). The host reads its
// operator's setting there; ai keeps no fee of its own.
func SetFees(f func(vendor string) string) {
if f == nil {
fees.Store(nil)
return
}
fees.Store(&f)
}
// Fee is a vendor's fee in percent as the host sets it, "" when no host sets one: a
// model resold from that vendor then bills at the vendor's price.
func Fee(vendor string) string {
if f := fees.Load(); f != nil {
return (*f)(vendor)
}
return ""
}