Skip to content

Commit

Permalink
Update OpenAI models + pricing
Browse files Browse the repository at this point in the history
  • Loading branch information
kharvd committed Aug 21, 2024
1 parent 086b48d commit d90b1b9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions gptcli/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def get_completion_provider(model: str) -> CompletionProvider:
model.startswith("gpt")
or model.startswith("ft:gpt")
or model.startswith("oai-compat:")
or model.startswith("chatgpt")
):
return OpenAICompletionProvider()
elif model.startswith("claude"):
Expand Down
18 changes: 16 additions & 2 deletions gptcli/providers/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,21 @@ def complete(
"response": 120.0 / 1_000_000,
}

GPT_4_O_PRICE_PER_TOKEN: Pricing = {
GPT_4_O_2024_05_13_PRICE_PER_TOKEN: Pricing = {
"prompt": 5.0 / 1_000_000,
"response": 15.0 / 1_000_000,
}

GPT_4_O_2024_08_06_PRICE_PER_TOKEN: Pricing = {
"prompt": 2.50 / 1_000_000,
"response": 10.0 / 1_000_000,
}

GPT_4_O_MINI_PRICE_PER_TOKEN: Pricing = {
"prompt": 0.150 / 1_000_000,
"response": 0.600 / 1_000_000,
}


def gpt_pricing(model: str) -> Optional[Pricing]:
if model.startswith("gpt-3.5-turbo-16k"):
Expand All @@ -120,8 +130,12 @@ def gpt_pricing(model: str) -> Optional[Pricing]:
return GPT_3_5_TURBO_PRICE_PER_TOKEN
elif model.startswith("gpt-4-32k"):
return GPT_4_32K_PRICE_PER_TOKEN
elif model.startswith("gpt-4o-mini"):
return GPT_4_O_MINI_PRICE_PER_TOKEN
elif model.startswith("gpt-4o-2024-05-13") or model.startswith("chatgpt-4o-latest"):
return GPT_4_O_2024_05_13_PRICE_PER_TOKEN
elif model.startswith("gpt-4o"):
return GPT_4_O_PRICE_PER_TOKEN
return GPT_4_O_2024_08_06_PRICE_PER_TOKEN
elif model.startswith("gpt-4-turbo") or re.match(r"gpt-4-\d\d\d\d-preview", model):
return GPT_4_TURBO_PRICE_PER_TOKEN
elif model.startswith("gpt-4"):
Expand Down

0 comments on commit d90b1b9

Please sign in to comment.