pricing

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pricing 按 Gemini API 公布的单价估算 Gemini Web 请求的等价费用

Index

Constants

View Source
const LongContext = 200_000

LongContext 是长上下文分档的输入 token 界限,输入超过该值的请求按长上下文单价计费

Variables

This section is empty.

Functions

This section is empty.

Types

type Price added in v0.2.0

type Price struct {
	Input      float64 `json:"input"`
	Output     float64 `json:"output"`
	LongInput  float64 `json:"long_input,omitempty"`
	LongOutput float64 `json:"long_output,omitempty"`
	Media      float64 `json:"media,omitempty"`
	Song       float64 `json:"song,omitempty"`
	// contains filtered or unexported fields
}

Price 是一个模型的美元单价:token 单价按每百万 token 计,Long 前缀为长上下文分档单价,0 表示不分档;Media 为生成图片或视频的模型回复 token 的单价;Song 为每个成功请求生成一首歌的单价

func Lookup added in v0.2.0

func Lookup(model string, at time.Time) (Price, bool)

Lookup 返回模型在 at 时刻生效的单价与模型是否有单价:先按模型 ID 本身查找,没有单价时按改名后的当前 ID 查找,模型 ID 的 -task 后缀不影响单价

func Served added in v0.2.0

func Served(model, provider string, at time.Time) (Price, bool)

Served 返回一条请求记录的单价:实际回答的模型有单价时用它,否则用请求的模型

func (Price) Cost added in v0.2.0

func (price Price) Cost(long bool, input, reasoning, reply, succeeded int64) float64

Cost 返回按单价估算的美元费用:long 表示长上下文分档,token 与 succeeded(成功的请求数)可以是同一分档多个请求之和

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL