Skip to content

Commit

Permalink
community[patch]: o1-preview and o1-mini costs (#26411)
Browse files Browse the repository at this point in the history
updated OpenAI cost definitions according to the following:
https://openai.com/api/pricing/

Co-authored-by: Erick Friis <[email protected]>
  • Loading branch information
ogawa65a and efriis authored Sep 17, 2024
1 parent 1a8e902 commit e2245fa
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libs/community/langchain_community/callbacks/openai_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
from langchain_core.outputs import ChatGeneration, LLMResult

MODEL_COST_PER_1K_TOKENS = {
# OpenAI o1-preview input
"o1-preview": 0.015,
"o1-preview-2024-09-12": 0.015,
# OpenAI o1-preview output
"o1-preview-completion": 0.06,
"o1-preview-2024-09-12-completion": 0.06,
# OpenAI o1-mini input
"o1-mini": 0.003,
"o1-mini-2024-09-12": 0.003,
# OpenAI o1-mini output
"o1-mini-completion": 0.012,
"o1-mini-2024-09-12-completion": 0.012,
# GPT-4o-mini input
"gpt-4o-mini": 0.00015,
"gpt-4o-mini-2024-07-18": 0.00015,
Expand Down Expand Up @@ -153,6 +165,7 @@ def standardize_model_name(
model_name.startswith("gpt-4")
or model_name.startswith("gpt-3.5")
or model_name.startswith("gpt-35")
or model_name.startswith("o1-")
or ("finetuned" in model_name and "legacy" not in model_name)
):
return model_name + "-completion"
Expand Down

0 comments on commit e2245fa

Please sign in to comment.