Skip to content

bmel:estimate-cost

Category: LLM · Returns: bmel:number

Signature
bmel:estimate-cost(tokens: bmel:integer, model: bmel:string)

Description

Returns the estimated cost in USD for a given number of tokens and a named model. Model identifiers follow the pattern used in the BizMetry agent catalog (e.g. 'gpt-4o', 'claude-3-5-sonnet', 'gemini-1.5-pro'). Pricing tables are maintained server-side and updated on model releases.

Arguments

Parameter Type Required Description
tokens bmel:integer Total token count (input + output combined, or split into separate calls for asymmetric pricing).
model bmel:string Model identifier string (e.g. 'gpt-4o', 'claude-3-5-sonnet', 'gemini-1.5-pro').

Examples

Cost of the tokens a call consumed
bmel:estimate-cost({invokeAgent:Response Payload}.$.usage.total_tokens, 'gpt-4o')
Cost with the model the call actually used
bmel:estimate-cost({invokeAgent:Response Payload}.$.usage.total_tokens, {invokeAgent:Response Payload}.$.model)
Total cost of the LLM calls of an agent run
bmel:sum(bmel:map({createChatCompletion:Response Payload[]}.$.usage.total_tokens, bmel:estimate-cost(bmel:item, 'gpt-4o-mini')))

← Back to BMEL Reference