Switchyard lets LLM applications route traffic across models and providers while preserving native OpenAI and Anthropic API compatibility - enabling flexible model selection, benchmarking, and cost/performance optimization.
Rust
feat(costs): add direct provider prices for Claude, Gemini, and DeepSeek (#1082)
Elyas Mehtabuddina526c5be110c
diff --git a/crates/switchyard-costs/prices.toml b/crates/switchyard-costs/prices.tomlindex c2e3ea5d6..ee8ec09d1 100644--- a/crates/switchyard-costs/prices.toml+++ b/crates/switchyard-costs/prices.toml@@ -245,3 +245,132 @@ output = 5cache_read = 0.1cache_write = 1.25cache_write_1h = 2++# These direct Claude IDs use Anthropic standard rates, checked on 2026-10-21.+# https://platform.claude.com/docs/en/about-claude/pricing+# Haiku 5.5 rates apply up to 100,000 prompt tokens. Longer prompts cost five times more.++["claude-opus-5"]+input = 5+output = 25+cache_read = 0.5+cache_write = 6.25+cache_write_1h = 10++["claude-fable-5"]+input = 10+output = 50+cache_read = 1+cache_write = 12.5+cache_write_1h = 20++["claude-fable-5-1"]+input = 10+output = 50+cache_read = 0.25+cache_write = 12.5+cache_write_1h = 20++["claude-haiku-5-5"]+input = 0.1+output = 0.5+cache_read = 0.01+cache_write = 0.125+cache_write_1h = 0.2++["claude-opus-4-6"]+input = 5+output = 25+cache_read = 0.5+cache_write = 6.25+cache_write_1h = 10++["claude-sonnet-4-6"]+input = 3+output = 15+cache_read = 0.3+cache_write = 3.75+cache_write_1h = 6++["claude-sonnet-4-5"]+input = 3+output = 15+cache_read = 0.3+cache_write = 3.75+cache_write_1h = 6++# Direct Gemini IDs use Google paid standard text rates, checked on 2026-10-21.+# https://ai.google.dev/gemini-api/docs/pricing+# The Argon promotion ends 2026-11-30. Its input, output, and cache-read rates then double.+# The Flash 3.6, 3.7, and 3.8 promotions end 2026-12-31. Their rates then double.+# Google bills cache storage by time, and this table excludes it.+# Separately counted cache writes, including one-hour writes, use the input rate.++["gemini-4-argon"]+input = 2+output = 10+cache_read = 0.1+cache_write = 2+cache_write_1h = 2++["gemini-3.8-flash"]+input = 0.75+output = 3.75+cache_read = 0.075+cache_write = 0.75+cache_write_1h = 0.75++["gemini-3.7-flash"]+input = 0.75+output = 3.75+cache_read = 0.075+cache_write = 0.75+cache_write_1h = 0.75++["gemini-3.6-flash"]+input = 0.75+output = 3.75+cache_read = 0.075+cache_write = 0.75+cache_write_1h = 0.75++["gemini-3.5-flash-lite"]+input = 0.3+output = 2.5+cache_read = 0.03+cache_write = 0.3+cache_write_1h = 0.3++# Direct DeepSeek IDs use peak rates, checked on 2026-10-21. Off-peak rates are half as much.+# https://api-docs.deepseek.com/quick_start/pricing/+# DeepSeek bills the older Flash IDs as deepseek-flash. This table uses one rate at all times.+# Separately counted cache writes, including one-hour writes, use the input rate.++["deepseek-flash"]+input = 0.3+output = 1.2+cache_read = 0.006+cache_write = 0.3+cache_write_1h = 0.3++["deepseek-v4-flash"]+input = 0.3+output = 1.2+cache_read = 0.006+cache_write = 0.3+cache_write_1h = 0.3++["deepseek-v4-flash-vision-exp"]+input = 0.3+output = 1.2+cache_read = 0.006+cache_write = 0.3+cache_write_1h = 0.3++["deepseek-v4-pro"]+input = 1.32+output = 3.96+cache_read = 0.044+cache_write = 1.32+cache_write_1h = 1.32+diff --git a/crates/switchyard-costs/src/lib.rs b/crates/switchyard-costs/src/lib.rsindex 8cb739fa9..6c9de8be5 100644--- a/crates/switchyard-costs/src/lib.rs+++ b/crates/switchyard-costs/src/lib.rs@@ -73,6 +73,11 @@ pub struct RecordedCost {}impl Pricing {+ /// This method reports whether the file includes rates for a model.+ pub fn contains(&self, model: &str) -> bool {+ self.0.contains_key(model)+ }+/// This method loads the rates shipped with this version of Switchyard.pub fn bundled() -> Result<Self, String> {Self::parse_toml(include_str!("../prices.toml"))diff --git a/crates/switchyard-menubar/README.md b/crates/switchyard-menubar/README.mdindex 8c31e1069..c58c9d0b3 100644--- a/crates/switchyard-menubar/README.md+++ b/crates/switchyard-menubar/README.md@@ -44,10 +44,13 @@ The server and menubar use the same [bundled rates](../switchyard-costs/prices.tdefault. To override them, point the server's `--pricing-file` and the menubar's`pricing_file` at the same TOML or JSON file. The file replaces the entire bundled table.Bundled rates stay fixed until you install a version with updated rates. The table-includes standard OpenAI and Claude text-token rates. Estimates exclude long-context-and service-tier adjustments, OpenAI's 12-hour cache-write pricing, tool fees, and-time-based cache storage. Entries with provider prefixes use list-rate estimates;-billed charges may differ. Use an override when your provider charges different rates.+includes text-token rates for OpenAI, Claude, Gemini, and DeepSeek models, plus OpenRouter+rates for other popular models. Direct-provider and OpenRouter rates use separate model+IDs, such as `gemini-3.8-flash` and `google/gemini-3.8-flash`. Estimates exclude+long-context and service-tier adjustments, OpenAI's 12-hour cache-write pricing, tool+fees, and time-based cache storage. Each model has one rate at all times of day. The+provider that OpenRouter selects can change the charge. Some Gemini rates are promotions;+the table lists their end dates. Use an override when your provider charges different rates.Key each entry by the model ID in the routing log. Rates are in USD per million tokens:```tomldiff --git a/crates/switchyard-server/README.md b/crates/switchyard-server/README.mdindex d10d31909..6b2d795cc 100644--- a/crates/switchyard-server/README.md+++ b/crates/switchyard-server/README.md@@ -126,12 +126,16 @@ routing logging is disabled.The routing log saves each call's reported charge in USD. When the upstream reports nocharge, the server estimates it using [bundled rates](../switchyard-costs/prices.toml).+A reported charge, including zero, takes precedence over the bundled rates.Bundled rates stay fixed until you install a version with updated rates.-The table includes OpenAI and Claude text-token rates. Model IDs match exactly,-including provider prefixes; an unlisted ID has no estimated cost.-These are standard-rate estimates. They exclude long-context and service-tier-adjustments, OpenAI's 12-hour cache-write pricing, tool fees, and time-based cache-storage. Entries with provider prefixes use list-rate estimates; billed charges may differ.+The table includes text-token rates for OpenAI, Claude, Gemini, and DeepSeek models, plus+OpenRouter rates for other popular models. Model IDs match exactly, including provider+prefixes; an unlisted ID has no estimated cost. Direct-provider and OpenRouter rates use+separate IDs, such as `gemini-3.8-flash` and `google/gemini-3.8-flash`.+Estimates exclude long-context and service-tier adjustments, OpenAI's 12-hour cache-write+pricing, tool fees, and time-based cache storage. Each model has one rate at all times of+day. Billed charges can differ when a gateway selects another provider or a promotion+ends. The table lists the Gemini promotion end dates.Use `--pricing-file prices.toml` to replace the entire bundled table with your own rates.Use a `.toml` file with quoted served model IDs and rates in USD per million tokens: