Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 20 additions & 0 deletions config/gemini-pricing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"models": {
"gemini-1.5-flash-latest": {
"prompt": 0.0005,
"completion": 0.0015
},
"gemini-1.5-pro-latest": {
"prompt": 0.0025,
"completion": 0.0075
},
"gemini-pro": {
"prompt": 0.0005,
"completion": 0.0015
}
},
"fallback": {
"prompt": 0.0005,
"completion": 0.0015
}
Comment on lines +2 to +27
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

Gemini API pricing per 1M tokens 2026 official: gemini-2.5-pro, gemini-2.5-flash, gemini-3.1-pro-preview, gemini-flash-latest, gemini-3.1-flash-lite-preview

💡 Result:

Gemini API Paid Tier pricing per 1M tokens (USD) as of April 2026 from official Google AI for Developers documentation (standard tier, text/image/video input unless noted; output includes thinking tokens; audio input higher where specified; Pro models tiered by prompt length <=200K / >200K tokens): - gemini-2.5-pro: Input $1.25 / $2.50, Output $10.00 / $15.00 - gemini-2.5-flash: Input $0.30 (text/image/video), $1.00 (audio); Output $2.50 - gemini-3.1-pro-preview: Input $2.00 / $4.00, Output $12.00 / $18.00 - gemini-flash-latest: Likely maps to latest stable Flash such as gemini-2.5-flash or gemini-3-flash-preview at Input $0.30-$0.50 / Output $2.50-$3.00 (exact alias pricing follows underlying model; no explicit separate rate found) - gemini-3.1-flash-lite-preview: Input $0.25 (text/image/video), $0.50 (audio); Output $1.50 Free tier available with limits (e.g., requests per day). Context caching and grounding extra. Batch/Priority tiers offer discounts/multipliers. Prices from ai.google.dev/gemini-api/docs/pricing (results 1,17+), Vertex AI docs (4,9,10), and consistent secondary confirmations (2,20,23,26,29). Vertex AI matches Developer API standard rates. "gemini-flash-latest" points to latest Flash release (e.g., 2.5 Flash per models docs), using 2.5 Flash rates conservatively as most cited stable.

Citations:


Pricing values are significantly below Google's published rates — cost estimates and --max-cost enforcement will be inaccurate.

Per Google's official Gemini API pricing (April 2026), the per‑1K-token costs in this file are 2–10× lower than reality:

Model Official (per 1K) This file (per 1K)
gemini-2.5-pro $0.00125 / $0.01 $0.0005 / $0.0015
gemini-2.5-flash $0.0003 / $0.0025 $0.000175 / $0.000525
gemini-3.1-pro-preview $0.002 / $0.012 $0.00125 / $0.005
gemini-3.1-flash-lite-preview $0.00025 / $0.0015 $0.0000375 / $0.00015

Since GeminiProvider.calculateCost() and dry‑run estimation read directly from this config (and the README pricing tables mirror it), a user who sets --max-cost 5.00 could be billed multiples of that on real runs. Note also that 2.5 Pro and 3.1 Pro have a long‑context (>200K tokens) tier at 2× — worth documenting if not modeling.

📐 Corrected values (from official ai.google.dev/gemini-api/docs/pricing)
   "models": {
     "gemini-2.5-pro": {
-      "prompt": 0.0005,
-      "completion": 0.0015
+      "prompt": 0.00125,
+      "completion": 0.01
     },
     "gemini-2.5-flash": {
-      "prompt": 0.000175,
-      "completion": 0.000525
+      "prompt": 0.0003,
+      "completion": 0.0025
     },
     "gemini-3.1-pro-preview": {
-      "prompt": 0.00125,
-      "completion": 0.005
+      "prompt": 0.002,
+      "completion": 0.012
     },
     "gemini-flash-latest": {
-      "prompt": 0.000175,
-      "completion": 0.000525
+      "prompt": 0.0003,
+      "completion": 0.0025
     },
     "gemini-3.1-flash-lite-preview": {
-      "prompt": 0.0000375,
-      "completion": 0.00015
+      "prompt": 0.00025,
+      "completion": 0.0015
     }
   },
   "fallback": {
-    "prompt": 0.0005,
-    "completion": 0.0015
+    "prompt": 0.00125,
+    "completion": 0.01
   }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@config/gemini-pricing.json` around lines 2 - 27, The pricing constants in
config/gemini-pricing.json are materially lower than Google's published April
2026 Gemini rates, which will make GeminiProvider.calculateCost() and
dry-run/--max-cost checks inaccurate; update each model entry (e.g.,
"gemini-2.5-pro", "gemini-2.5-flash", "gemini-3.1-pro-preview",
"gemini-flash-latest", "gemini-3.1-flash-lite-preview") and the "fallback"
values to the official per‑1K token prompt and completion prices from Google's
Gemini pricing page, and add/annotate the long‑context (>200K) tier (2×
multiplier) for 2.5 Pro and 3.1 Pro where appropriate so cost calculations and
README tables match production billing and enforcement performed by
GeminiProvider.calculateCost().

}
14 changes: 12 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
},
"scripts": {
"translate": "./potomatic",
"translate:gemini": "./potomatic --provider gemini",
"ab-prompt-test": "node tools/ab-prompt-test",
"test": "vitest run",
"test:watch": "vitest",
Expand All @@ -45,6 +46,7 @@
"node": ">=18"
},
"dependencies": {
"@google/generative-ai": "^0.24.1",
"chalk": "^5.3.0",
"commander": "^12.0.0",
"dotenv": "^16.5.0",
Expand Down
3 changes: 2 additions & 1 deletion src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ export function parseCliArguments() {
.option('--locale-format <format>', 'Format to use for locale codes in file names: `wp_locale` (ru_RU), `iso_639_1` (ru), `iso_639_2` (rus), or `target_lang` (default)', DEFAULTS.LOCALE_FORMAT)

// === Translation Options ==.=
.option('-k, --api-key <key>', 'OpenAI API key (overrides API_KEY env var)')
.option('--provider <provider>', 'AI provider to use (e.g., "openai", "gemini")', DEFAULTS.PROVIDER)
.option('-k, --api-key <key>', 'Provider API key (overrides API_KEY env var)')
.option('-m, --model <model>', 'AI model name (e.g., "gpt-4o-mini")', DEFAULTS.MODEL)
.option('--temperature <number>', 'Creativity level (0.0-2.0); lower = more deterministic, higher = more creative', (val) => Math.max(0, Math.min(2, parseFloat(val))), DEFAULTS.TEMPERATURE)
.option('-F, --force-translate', 'Re-translate all strings, ignoring any existing translations', DEFAULTS.FORCE_TRANSLATE)
Expand Down
17 changes: 16 additions & 1 deletion src/providers/ProviderFactory.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { OpenAIProvider } from './openai/OpenAIProvider.js';
import { GeminiProvider } from './gemini/GeminiProvider.js';

/**
* Creates and configures AI translation providers based on configuration.
Expand Down Expand Up @@ -26,6 +27,8 @@ export class ProviderFactory {
switch (providerName.toLowerCase()) {
case 'openai':
return new OpenAIProvider(config, logger);
case 'gemini':
return new GeminiProvider(config, logger);
default:
throw new Error(`Unsupported provider: ${providerName}. ` + `Supported providers: ${ProviderFactory.getSupportedProviders().join(', ')}`);
}
Expand All @@ -39,7 +42,7 @@ export class ProviderFactory {
* @return {Array<string>} Array of supported provider names.
*/
static getSupportedProviders() {
return ['openai'];
return ['openai', 'gemini'];
}

/**
Expand Down Expand Up @@ -76,6 +79,18 @@ export class ProviderFactory {
model: 'gpt-3.5-turbo',
},
},
{
name: 'gemini',
displayName: 'Google Gemini',
description: 'Google Gemini models',
status: 'implemented',
models: ['gemini-2.5-pro', 'gemini-2.5-flash', 'gemini-2.5-flash-lite'],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Model names inconsistency across files

The models listed here (gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite) don't match the models in config/gemini-pricing.json (gemini-1.5-flash-latest, gemini-1.5-pro-latest, gemini-pro). This will cause issues when users try to use the models shown in provider info.

Please ensure consistency between:

  • The pricing configuration models
  • The provider info models
  • The actual supported models in GeminiProvider

Consider updating either the pricing config or this provider info to match.

🤖 Prompt for AI Agents
In src/providers/ProviderFactory.js at line 87, the model names listed are
inconsistent with those in config/gemini-pricing.json and the actual supported
models in GeminiProvider. To fix this, update the models array here to exactly
match the model names used in the pricing configuration and supported by
GeminiProvider, ensuring all three sources use the same model identifiers for
consistency.

configExample: {
provider: 'gemini',
apiKey: 'your-gemini-api-key',
model: 'gemini-2.5-flash',
},
},
];
}

Expand Down
Loading