From 54d87d8806197f076b939d30084a90ec9627c851 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 3 Aug 2025 06:57:36 +0000 Subject: [PATCH] Update pricing tables in README and pricing_table.md with latest models Co-authored-by: alex --- README.md | 17 ++++++++++++++++- update_prices.py | 24 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b0841c..125ad28 100644 --- a/README.md +++ b/README.md @@ -119,4 +119,19 @@ For Anthropic models above version 3 (i.e. Sonnet 3.5, Haiku 3.5, and Opus 3), w ## Cost table -Units denominated in USD. All prices can be located [here](pricing_table.md). \ No newline at end of file +Units denominated in USD. All prices can be located [here](pricing_table.md). + +| Model Name | Prompt Cost (USD) per 1M tokens | Completion Cost (USD) per 1M tokens | Max Prompt Tokens | Max Output Tokens | +|:----------------------------------------------------------------------|:----------------------------------|:--------------------------------------|:--------------------|--------------------:| +| gpt-4 | $30 | $60 | 8192 | 4096 | +| gpt-4o | $2.5 | $10 | 128,000 | 16384 | +| gpt-4o-audio-preview | $2.5 | $10 | 128,000 | 16384 | +| gpt-4o-audio-preview-2024-10-01 | $2.5 | $10 | 128,000 | 16384 | +| gpt-4o-mini | $0.15 | $0.6 | 128,000 | 16384 | +| gpt-4o-mini-2024-07-18 | $0.15 | $0.6 | 128,000 | 16384 | +| o1-mini | $1.1 | $4.4 | 128,000 | 65536 | +| o1-mini-2024-09-12 | $3 | $12 | 128,000 | 65536 | +| o1-preview | $15 | $60 | 128,000 | 32768 | +| o1-preview-2024-09-12 | $15 | $60 | 128,000 | 32768 | + +**Note:** This table shows a subset of available models. For the complete list of models and pricing, see [pricing_table.md](pricing_table.md). \ No newline at end of file diff --git a/update_prices.py b/update_prices.py index 4a5b769..fc1a7be 100644 --- a/update_prices.py +++ b/update_prices.py @@ -2,6 +2,7 @@ import tokencost from decimal import Decimal import json +import re # Update model_prices.json with the latest costs from the LiteLLM cost tracker print("Fetching latest prices...") @@ -122,3 +123,26 @@ def format_cost(x): f.write(table_md) print("Pricing table updated in pricing_table.md") + +# Read the README.md file +with open("README.md", "r") as f: + readme_content = f.read() + +# Find and replace just the table in the README, preserving the header text +# The regex pattern matches a markdown table starting with the "Model Name" header +# and ending before the "Note:" line +table_pattern = r"(?s)\| Model Name.*?(?=\n\n\*\*Note:\*\*)" + +# Get a subset of the table (first 10 rows) for the README +table_lines = table_md.split('\n') +subset_table = '\n'.join(table_lines[:12]) # Header + separator + first 10 data rows + +table_replacement = subset_table + +updated_readme = re.sub(table_pattern, table_replacement, readme_content, flags=re.DOTALL) + +# Write the updated README +with open("README.md", "w") as f: + f.write(updated_readme) + +print("README.md updated with the latest pricing table")