Skip to content

Commit

Permalink
add more costs (#2072)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwlee64 authored Aug 5, 2024
1 parent 83efe6f commit 52374bc
Show file tree
Hide file tree
Showing 2 changed files with 632 additions and 94 deletions.
96 changes: 2 additions & 94 deletions weave-js/src/util/llmTokenCosts.ts
Original file line number Diff line number Diff line change
@@ -1,102 +1,10 @@
import {LLM_TOKEN_COSTS} from './tokenCosts';

export type Model = keyof typeof LLM_TOKEN_COSTS;
export const isValidLLMModel = (model: string): model is Model => {
return Object.keys(LLM_TOKEN_COSTS).includes(model);
};

export const LLM_TOKEN_COSTS = {
// Default pricing if model has no specific pricing
default: {
input: 0.005,
output: 0.015,
},

// OPENAI pricing for 1k LLM tokens taken on June 4, 2024
// https://openai.com/api/pricing/
'gpt-4o': {
input: 0.005,
output: 0.015,
},
'gpt-4o-2024-05-13': {
input: 0.005,
output: 0.015,
},
'gpt-4-turbo': {
input: 0.01,
output: 0.03,
},
'gpt-4-turbo-2024-04-09': {
input: 0.01,
output: 0.03,
},
'gpt-4': {
input: 0.03,
output: 0.06,
},
'gpt-4-32k': {
input: 0.06,
output: 0.12,
},
'gpt-4-0125-preview': {
input: 0.01,
output: 0.03,
},
'gpt-4-1106-preview': {
input: 0.01,
output: 0.03,
},
'gpt-4-vision-preview': {
input: 0.01,
output: 0.03,
},
'gpt-3.5-turbo-1106': {
input: 0.001,
output: 0.002,
},
'gpt-3.5-turbo-0613': {
input: 0.0015,
output: 0.002,
},
'gpt-3.5-turbo-16k-0613': {
input: 0.003,
output: 0.004,
},
'gpt-3.5-turbo-0301': {
input: 0.0015,
output: 0.002,
},
'gpt-3.5-turbo-0125': {
input: 0.0005,
output: 0.0015,
},
'gpt-3.5-turbo-instruct': {
input: 0.0015,
output: 0.002,
},
'davinci-002': {
input: 0.002,
output: 0.002,
},
'babbage-002': {
input: 0.0004,
output: 0.0004,
},

// Anthropic pricing for 1k LLM tokens taken on June 4, 2024
// https://docs.anthropic.com/en/docs/models-overview
'claude-3-opus-20240229': {
input: 0.015,
output: 0.075,
},
'claude-3-sonnet-20240229': {
input: 0.003,
output: 0.015,
},
'claude-3-haiku-20240307': {
input: 0.00025,
output: 0.00125,
},
};

export const getLLMTokenCost = (
model: string,
type: 'input' | 'output',
Expand Down
Loading

0 comments on commit 52374bc

Please sign in to comment.