-
-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: update openai websearch price #1549
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
Conversation
WalkthroughThe change updates the pricing logic and accompanying comments for web search models within a single file. The condition for assigning models to different price tiers was revised, specifically changing which model names are matched for the lower price tier. No changes were made to function signatures or public interfaces. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant ToolsGo
Caller->>ToolsGo: GetWebSearchPricePerThousand(modelName, contextSize)
alt modelName starts with "gpt-5" or is "o" series
ToolsGo-->>Caller: Return $10.00 per 1K calls (extra tokens counted)
else modelName is "gpt-4o" or "gpt-4.1" series
ToolsGo-->>Caller: Return $25.00 per 1K calls (no extra tokens)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Possibly related PRs
Poem
Note 🔌 MCP (Model Context Protocol) integration is now available in Early Access!Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
setting/operation_setting/tools.go (1)
31-34
:contextSize
parameter is now dead codeThe comment says pricing no longer depends on context size, yet
contextSize
remains in the signature and is never used.
Removing it (or marking as deprecated) will prevent confusion for future callers.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
setting/operation_setting/tools.go
(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-21T03:37:41.726Z
Learnt from: 9Ninety
PR: QuantumNous/new-api#1273
File: relay/channel/gemini/relay-gemini.go:97-116
Timestamp: 2025-06-21T03:37:41.726Z
Learning: In relay/channel/gemini/relay-gemini.go, the thinking budget calculation logic (including the MaxOutputTokens multiplication) was introduced in PR #1247. PR #1273 focused specifically on decoupling the thoughts summary feature from thinking budget settings and did not modify the existing thinking budget behavior.
Applied to files:
setting/operation_setting/tools.go
strings.HasPrefix(modelName, "o3") || | ||
strings.HasPrefix(modelName, "o4") || | ||
strings.Contains(modelName, "deep-research") | ||
strings.HasPrefix(modelName, "gpt-5") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Model-prefix check may miss future “o” versions
Only o3
and o4
prefixes are treated as the low-tier models.
If OpenAI releases o5
(or any other o*
) the code will silently charge the higher price.
Consider matching the whole family, e.g.:
isNormalPriceModel :=
strings.HasPrefix(modelName, "o") ||
strings.HasPrefix(modelName, "gpt-5")
or keep an allow-list constant that is easier to extend.
🏁 Script executed:
#!/bin/bash
set -e
# Locate the tools.go file under operation_setting
file=$(fd "tools.go" | grep "setting/operation_setting/tools.go" | head -n 1)
echo "Found file: $file"
# Print the first 200 lines to inspect the function definition and usage
echo -e "\n--- File content (lines 1–200) ---"
sed -n '1,200p' "$file"
# Search for contextSize occurrences in the file
echo -e "\n--- contextSize occurrences ---"
grep -n "contextSize" "$file" || echo "No occurrences of contextSize found"
Length of output: 2693
Update model-prefix logic and remove unused contextSize
parameter
- Remove the unused
contextSize
parameter fromGetWebSearchPricePerThousand
(both signature and all call sites). - Broaden the “o”-series match so future variants (e.g.
o5
) fall under the normal-price tier. - Example diff:
--- a/setting/operation_setting/tools.go
+++ b/setting/operation_setting/tools.go
@@ -28,7 +28,7 @@
- func GetWebSearchPricePerThousand(modelName string, contextSize string) float64 {
+ func GetWebSearchPricePerThousand(modelName string) float64 {
// …pricing comments…
- isNormalPriceModel :=
- strings.HasPrefix(modelName, "o3") ||
- strings.HasPrefix(modelName, "o4") ||
- strings.HasPrefix(modelName, "gpt-5")
+ isNormalPriceModel :=
+ strings.HasPrefix(modelName, "o") ||
+ strings.HasPrefix(modelName, "gpt-5")
var priceWebSearchPerThousandCalls float64
if isNormalPriceModel {
priceWebSearchPerThousandCalls = WebSearchPrice
By matching "o"
you ensure any future o-series models use the correct rate.
🤖 Prompt for AI Agents
In setting/operation_setting/tools.go around lines 38 to 40, remove the unused
contextSize parameter from the GetWebSearchPricePerThousand function signature
and all its call sites. Update the model prefix matching logic by replacing the
specific "o3" and "o4" prefixes with a broader check for any model starting with
"o" to include future variants like "o5" under the normal-price tier. Adjust the
strings.HasPrefix conditions accordingly to match "o" instead of specific
versions.
更新 web search tool 价格,适配 gpt-5
https://platform.openai.com/docs/pricing?latest-pricing=standard#built-in-tools
Summary by CodeRabbit