Skip to content

feat: add GPT-5 model family pricing support #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions libs/community/langchain_community/callbacks/openai_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,37 @@
from langchain_core.outputs import ChatGeneration, LLMResult

MODEL_COST_PER_1K_TOKENS = {
# GPT-5 input
"gpt-5": 0.00125,
"gpt-5-cached": 0.000125,
"gpt-5-2025-08-07": 0.00125,
"gpt-5-2025-08-07-cached": 0.000125,
# GPT-5 output
"gpt-5-completion": 0.01,
# GPT-5-mini input
"gpt-5-mini": 0.00025,
"gpt-5-mini-cached": 0.000025,
"gpt-5-mini-2025-08-07": 0.00025,
"gpt-5-mini-2025-08-07-cached": 0.000025,
# GPT-5-mini output
"gpt-5-mini-completion": 0.002,
"gpt-5-mini-2025-08-07-completion": 0.002,
# GPT-5-nano input
"gpt-5-nano": 0.00005,
"gpt-5-nano-cached": 0.000005,
"gpt-5-nano-2025-08-07": 0.00005,
"gpt-5-nano-2025-08-07-cached": 0.000005,
# GPT-5-nano output
"gpt-5-nano-completion": 0.0004,
"gpt-5-nano-2025-08-07-completion": 0.0004,
# GPT-5-chat-latest input
"gpt-5-chat-latest": 0.00125,
"gpt-5-chat-latest-cached": 0.000125,
"gpt-5-chat-latest-2025-08-07": 0.00125,
"gpt-5-chat-latest-2025-08-07-cached": 0.000125,
# GPT-5-chat-latest output
"gpt-5-chat-latest-completion": 0.01,
"gpt-5-chat-latest-2025-08-07-completion": 0.01,
# GPT-4.1 input
"gpt-4.1": 0.002,
"gpt-4.1-2025-04-14": 0.002,
Expand Down Expand Up @@ -42,6 +73,8 @@
# GPT-4.5-preview output
"gpt-4.5-preview-completion": 0.15,
"gpt-4.5-preview-2025-02-27-completion": 0.15,


# OpenAI o1 input
"o1": 0.015,
"o1-2024-12-17": 0.015,
Expand Down Expand Up @@ -319,7 +352,8 @@ def standardize_model_name(
if "ft:" in model_name:
model_name = model_name.split(":")[1] + "-finetuned"
if token_type == TokenType.COMPLETION and (
model_name.startswith("gpt-4")
model_name.startswith("gpt-5")
or model_name.startswith("gpt-4")
or model_name.startswith("gpt-3.5")
or model_name.startswith("gpt-35")
or model_name.startswith("o1-")
Expand All @@ -331,7 +365,8 @@ def standardize_model_name(
if (
token_type == TokenType.PROMPT_CACHED
and (
model_name.startswith("gpt-4o")
model_name.startswith("gpt-5")
or model_name.startswith("gpt-4o")
or model_name.startswith("gpt-4.1")
or model_name.startswith("o1")
or model_name.startswith("o3")
Expand Down