Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 11 additions & 2 deletions relay/channel/openai/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,25 @@ var ModelList = []string{
"gpt-4o", "gpt-4o-2024-05-13", "gpt-4o-2024-08-06", "gpt-4o-2024-11-20",
"gpt-4o-mini", "gpt-4o-mini-2024-07-18",
"gpt-4.5-preview", "gpt-4.5-preview-2025-02-27",
"gpt-4.1", "gpt-4.1-2025-04-14",
"gpt-4.1-mini", "gpt-4.1-mini-2025-04-14",
"gpt-4.1-nano", "gpt-4.1-nano-2025-04-14",
"o1", "o1-2024-12-17",
"o1-preview", "o1-preview-2024-09-12",
"o1-mini", "o1-mini-2024-09-12",
"o1-pro", "o1-pro-2025-03-19",
"o3-mini", "o3-mini-2025-01-31",
"o3-mini-high", "o3-mini-2025-01-31-high",
"o3-mini-low", "o3-mini-2025-01-31-low",
"o3-mini-medium", "o3-mini-2025-01-31-medium",
"o3", "o3-2025-04-16",
"o3-pro", "o3-pro-2025-06-10",
"o3-deep-research", "o3-deep-research-2025-06-26",
"o4-mini", "o4-mini-2025-04-16",
"o4-mini-deep-research", "o4-mini-deep-research-2025-06-26",
"gpt-5", "gpt-5-2025-08-07", "gpt-5-chat-latest",
"gpt-5-mini", "gpt-5-mini-2025-08-07",
"gpt-5-nano", "gpt-5-nano-2025-08-07",
"o1", "o1-2024-12-17",
"gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-10-01",
"gpt-4o-realtime-preview", "gpt-4o-realtime-preview-2024-10-01", "gpt-4o-realtime-preview-2024-12-17",
"gpt-4o-mini-realtime-preview", "gpt-4o-mini-realtime-preview-2024-12-17",
Expand All @@ -30,7 +39,7 @@ var ModelList = []string{
"text-moderation-latest", "text-moderation-stable",
"text-davinci-edit-001",
"davinci-002", "babbage-002",
"dall-e-3",
"dall-e-3", "gpt-image-1",
"whisper-1",
"tts-1", "tts-1-1106", "tts-1-hd", "tts-1-hd-1106",
}
Expand Down
32 changes: 25 additions & 7 deletions setting/ratio_setting/model_ratio.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,21 @@ var defaultModelRatio = map[string]float64{
"gpt-4o-realtime-preview-2024-12-17": 2.5,
"gpt-4o-mini-realtime-preview": 0.3,
"gpt-4o-mini-realtime-preview-2024-12-17": 0.3,
"gpt-image-1": 2.5,
"o1": 7.5,
"o1-2024-12-17": 7.5,
"o1-preview": 7.5,
"o1-preview-2024-09-12": 7.5,
"o1-mini": 0.55,
"o1-mini-2024-09-12": 0.55,
"gpt-4.1": 1.0, // $2 / 1M tokens
"gpt-4.1-2025-04-14": 1.0, // $2 / 1M tokens
"gpt-4.1-mini": 0.2, // $0.4 / 1M tokens
"gpt-4.1-mini-2025-04-14": 0.2, // $0.4 / 1M tokens
"gpt-4.1-nano": 0.05, // $0.1 / 1M tokens
"gpt-4.1-nano-2025-04-14": 0.05, // $0.1 / 1M tokens
"gpt-image-1": 2.5, // $5 / 1M tokens
Comment on lines +55 to +61

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Sanity check: ensure every new OpenAI model has a default ratio and reasonable completion ratio

All new models have defaultModelRatio entries, but completion ratio coverage for o4 is likely missing as noted. To be safe, run this repo-local check to confirm coverage and catch any misses between ModelList and defaultModelRatio.

Also applies to: 62-69, 78-87


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Pull all OpenAI models from the list
const_file="relay/channel/openai/constant.go"
ratio_file="setting/ratio_setting/model_ratio.go"

# Extract all model names from ModelList
models=$(sed -n '/var ModelList = \[]string{/,/}/p' "$const_file" | \
  rg -o '"[^"]+"' | tr -d '"')

# Filter to newly introduced families for this PR
new_patterns='^(gpt-4\.1|o3|o4-mini|gpt-image-1|o1-pro)'
new_models=$(printf "%s\n" "$models" | rg -nP "$new_patterns" | cut -d: -f2-)

# Extract keys from defaultModelRatio map
ratio_keys=$(sed -n '/var defaultModelRatio = map\[string\]float64{/,/}/p' "$ratio_file" | \
  rg -o '"[^"]+"' | tr -d '"')

echo "Checking new models have defaultModelRatio entries..."
missing=""
while IFS= read -r m; do
  if ! printf "%s\n" "$ratio_keys" | rg -qx "$m" >/dev/null; then
    missing+="$m"$'\n'
  fi
done <<< "$new_models"

if [ -n "$missing" ]; then
  echo "Missing ratios for:"
  printf "%s" "$missing"
  exit 1
else
  echo "OK: All new models found in defaultModelRatio."
fi

echo
echo "Checking defaultModelPrice has gpt-image-1 (optional, only if price used for images)..."
price_keys=$(sed -n '/var defaultModelPrice = map\[string\]float64{/,/}/p' "$ratio_file" | \
  rg -o '"[^"]+"' | tr -d '"')
if printf "%s\n" "$price_keys" | rg -qx "gpt-image-1" >/dev/null; then
  echo "OK: gpt-image-1 present in defaultModelPrice"
else
  echo "Note: gpt-image-1 not present in defaultModelPrice"
fi

echo
echo "Checking whether hardcoded completion ratios cover o4..."
if rg -n 'HasPrefix\(name,\s*"o4"\)' "$ratio_file" >/dev/null; then
  echo "OK: o4 present in getHardcodedCompletionModelRatio"
else
  echo "Note: o4 not covered in getHardcodedCompletionModelRatio; will default to 1"
fi

Length of output: 116360


Sanity check results — defaultModelRatio OK; defaultModelPrice missing gpt-image-1; o4 completion ratio not covered (fix required)

Ran the repo-local check you included. Findings:

  • OK: All new models from relay/channel/openai/constant.go (gpt-4.1*, o3*, o4-mini*, o1-pro, gpt-image-1) are present in var defaultModelRatio (setting/ratio_setting/model_ratio.go).
  • Action required: var defaultModelPrice in setting/ratio_setting/model_ratio.go does NOT include "gpt-image-1" — add a price entry if image pricing is used.
  • Action required: getHardcodedCompletionModelRatio in setting/ratio_setting/model_ratio.go has no HasPrefix(name, "o4") branch — add coverage for the o4 family (otherwise completion ratio will default to 1).

Files to update:

  • setting/ratio_setting/model_ratio.go (defaultModelPrice, getHardcodedCompletionModelRatio)
  • (reference) relay/channel/openai/constant.go (ModelList)

Please add the missing price entry and an o4 case (with an appropriate completion ratio) and re-run the check.

"o1": 7.5, // $15 / 1M tokens
"o1-2024-12-17": 7.5, // $15 / 1M tokens
"o1-preview": 7.5, // $15 / 1M tokens
"o1-preview-2024-09-12": 7.5, // $15 / 1M tokens
"o1-mini": 0.55, // $1.1 / 1M tokens
"o1-mini-2024-09-12": 0.55, // $1.1 / 1M tokens
"o1-pro": 75.0, // $150 / 1M tokens
"o1-pro-2025-03-19": 75.0, // $150 / 1M tokens
"o3-mini": 0.55,
"o3-mini-2025-01-31": 0.55,
"o3-mini-high": 0.55,
Expand All @@ -67,6 +75,16 @@ var defaultModelRatio = map[string]float64{
"o3-mini-2025-01-31-low": 0.55,
"o3-mini-medium": 0.55,
"o3-mini-2025-01-31-medium": 0.55,
"o3": 1.0, // $2 / 1M tokens
"o3-2025-04-16": 1.0, // $2 / 1M tokens
"o3-pro": 10.0, // $20 / 1M tokens
"o3-pro-2025-06-10": 10.0, // $20 / 1M tokens
"o3-deep-research": 5.0, // $10 / 1M tokens
"o3-deep-research-2025-06-26": 5.0, // $10 / 1M tokens
"o4-mini": 0.55, // $1.1 / 1M tokens
"o4-mini-2025-04-16": 0.55, // $1.1 / 1M tokens
"o4-mini-deep-research": 1.0, // $2 / 1M tokens
"o4-mini-deep-research-2025-06-26": 1.0, // $2 / 1M tokens
"gpt-4o-mini": 0.075,
"gpt-4o-mini-2024-07-18": 0.075,
"gpt-4-turbo": 5, // $0.01 / 1K tokens
Expand Down