MCPcopy Create free account
hub / github.com/InfinitiBit/graphbit / estimate_cost

Method estimate_cost

core/src/llm/response.rs:86–89  ·  view source on GitHub ↗

Estimate the cost of this response (if cost per token is known)

(&self, input_cost_per_token: f64, output_cost_per_token: f64)

Source from the content-addressed store, hash-verified

84
85 /// Estimate the cost of this response (if cost per token is known)
86 pub fn estimate_cost(&self, input_cost_per_token: f64, output_cost_per_token: f64) -> f64 {
87 (self.usage.prompt_tokens as f64 * input_cost_per_token)
88 + (self.usage.completion_tokens as f64 * output_cost_per_token)
89 }
90}
91
92/// Token usage statistics

Callers 2

test_cost_estimationFunction · 0.80

Calls

no outgoing calls

Tested by 2

test_cost_estimationFunction · 0.64