langfuse-model-upsert

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Langfuse Model Upsert

Langfuse 模型新增或更新

Create or update model pricing information.
创建或更新模型定价信息。

Setup

前置设置

Set the following environment variables before use:
VariableRequiredDescription
LANGFUSE_PUBLIC_KEY
YesLangfuse public key
LANGFUSE_SECRET_KEY
YesLangfuse secret key
LANGFUSE_HOST
or
LANGFUSE_BASE_URL
NoLangfuse host URL (default:
https://us.cloud.langfuse.com
)
使用前请设置以下环境变量:
变量名是否必填说明
LANGFUSE_PUBLIC_KEY
Langfuse公钥
LANGFUSE_SECRET_KEY
Langfuse密钥
LANGFUSE_HOST
LANGFUSE_BASE_URL
Langfuse主机地址(默认值:
https://us.cloud.langfuse.com

When to Use

适用场景

  • Setting model pricing
  • Adding a new model
  • Updating pricing
  • 设置模型定价
  • 添加新模型
  • 更新定价

Commands

命令说明

1. Set Model Pricing

1. 设置模型定价

bash
npx tsx scripts/langfuse-model-upsert.ts "<model-name>" --input <input-price> --output <output-price>
bash
npx tsx scripts/langfuse-model-upsert.ts "<model-name>" --input <input-price> --output <output-price>

2. With Custom Match Pattern

2. 自定义匹配规则

bash
npx tsx scripts/langfuse-model-upsert.ts "<model-name>" --input <input-price> --output <output-price> --pattern "<regex>"
bash
npx tsx scripts/langfuse-model-upsert.ts "<model-name>" --input <input-price> --output <output-price> --pattern "<regex>"

Examples

使用示例

bash
undefined
bash
undefined

Set pricing for Groq qwen3-32b

为Groq qwen3-32b设置定价

npx tsx scripts/langfuse-model-upsert.ts "qwen/qwen3-32b" --input 0.29 --output 0.59
npx tsx scripts/langfuse-model-upsert.ts "qwen/qwen3-32b" --input 0.29 --output 0.59

Set pricing for Fireworks deepseek-v3 (with pattern)

为Fireworks deepseek-v3设置定价(带匹配规则)

npx tsx scripts/langfuse-model-upsert.ts "deepseek-v3" --input 0.20 --output 0.60 --pattern ".deepseek-v3."
undefined
npx tsx scripts/langfuse-model-upsert.ts "deepseek-v3" --input 0.20 --output 0.60 --pattern ".deepseek-v3."
undefined

Output Example

输出示例

Updating existing model: qwen/qwen3-32b
  Current: input=$0.20, output=$0.40
  Deleted old model definition

Model updated successfully!
  Model Name: qwen/qwen3-32b
  Input Price: $0.29/1M tokens
  Output Price: $0.59/1M tokens
Updating existing model: qwen/qwen3-32b
  Current: input=$0.20, output=$0.40
  Deleted old model definition

Model updated successfully!
  Model Name: qwen/qwen3-32b
  Input Price: $0.29/1M tokens
  Output Price: $0.59/1M tokens

Parameters

参数说明

ParameterDescription
<model-name>
Model identifier (required)
--input
Cost per 1M input tokens (USD)
--output
Cost per 1M output tokens (USD)
--pattern
Regex pattern for model name matching (default: exact match)
参数说明
<model-name>
模型标识符(必填)
--input
每百万输入Token的成本(美元)
--output
每百万输出Token的成本(美元)
--pattern
模型名称匹配的正则表达式(默认:精确匹配)

Notes

注意事项

  • Prices are in USD per 1M tokens
  • Existing models are deleted and re-created (update)
  • If no pattern is specified, the model name is used as an exact match
  • 价格单位为美元每百万Token
  • 现有模型会先删除再重新创建(即更新操作)
  • 若未指定匹配规则,则使用模型名称进行精确匹配