123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251letp?cached?cache_write_5m?cache_write_1h?per_image?per_second~input~output()=Cost.pricing?cached_per_million:cached?cache_write_per_million:cache_write_5m?cache_write_1h_per_million:cache_write_1h?per_image?per_second~input_per_million:input~output_per_million:output()letall=[("gpt-5.6-sol",p~input:5.0~output:30.0~cached:0.5());("gpt-5.6-terra",p~input:2.5~output:15.0~cached:0.25());("gpt-5.6-luna",p~input:1.0~output:6.0~cached:0.1());("gpt-5.5",p~input:5.0~output:30.0~cached:0.5());("gpt-5.5-pro",p~input:30.0~output:180.0());("gpt-5.4",p~input:2.5~output:15.0~cached:0.25());("gpt-5.4-mini",p~input:0.75~output:4.5~cached:0.075());("gpt-5.4-nano",p~input:0.2~output:1.25~cached:0.02());("gpt-5.4-pro",p~input:30.0~output:180.0());("gpt-5.2",p~input:1.75~output:14.0~cached:0.175());("gpt-5.2-pro",p~input:21.0~output:168.0());("gpt-5.2-codex",p~input:1.75~output:14.0~cached:0.175());("gpt-5.1",p~input:1.25~output:10.0~cached:0.125());("gpt-5.1-codex",p~input:1.25~output:10.0~cached:0.125());("gpt-5.1-codex-max",p~input:1.25~output:10.0~cached:0.125());("gpt-5.1-codex-mini",p~input:0.25~output:2.0~cached:0.025());("gpt-5",p~input:1.25~output:10.0~cached:0.125());("gpt-5-pro",p~input:15.0~output:120.0());("gpt-5-mini",p~input:0.25~output:2.0~cached:0.025());("gpt-5-nano",p~input:0.05~output:0.4~cached:0.005());("gpt-5-codex",p~input:1.25~output:10.0~cached:0.125());("gpt-5-image",p~input:10.0~output:10.0~cached:1.25());("gpt-5-image-mini",p~input:2.5~output:2.0~cached:0.25());("gpt-4o",p~input:2.5~output:10.0~cached:1.25());("gpt-4o-2024-11-20",p~input:2.5~output:10.0~cached:1.25());("gpt-4o-2024-08-06",p~input:2.5~output:10.0~cached:1.25());("gpt-4o-2024-05-13",p~input:5.0~output:15.0());("gpt-4o-mini",p~input:0.15~output:0.6~cached:0.075());("gpt-4o-mini-2024-07-18",p~input:0.15~output:0.6~cached:0.075());("gpt-4.1",p~input:2.0~output:8.0~cached:0.5());("gpt-4.1-mini",p~input:0.4~output:1.6~cached:0.1());("gpt-4.1-nano",p~input:0.1~output:0.4~cached:0.025());("gpt-4-turbo",p~input:5.0~output:15.0());("gpt-4-turbo-2024-04-09",p~input:5.0~output:15.0());("gpt-4-turbo-preview",p~input:5.0~output:15.0());("gpt-4",p~input:30.0~output:60.0());("gpt-4-0613",p~input:30.0~output:60.0());("gpt-4-32k",p~input:60.0~output:120.0());("gpt-3.5-turbo",p~input:0.5~output:1.5());("gpt-3.5-turbo-0125",p~input:0.5~output:1.5());("gpt-3.5-turbo-16k",p~input:3.0~output:4.0());("o1",p~input:15.0~output:60.0~cached:7.5());("o1-2024-12-17",p~input:15.0~output:60.0~cached:7.5());("o1-preview",p~input:15.0~output:60.0());("o1-mini",p~input:3.0~output:12.0());("o1-pro",p~input:150.0~output:600.0());("o3",p~input:2.0~output:8.0~cached:0.5());("o3-2025-04-16",p~input:2.0~output:8.0~cached:0.5());("o3-mini",p~input:1.1~output:4.4~cached:0.55());("o3-mini-2025-01-31",p~input:1.1~output:4.4~cached:0.55());("o3-pro",p~input:20.0~output:80.0());("o3-deep-research",p~input:10.0~output:40.0~cached:2.5());("o4-mini",p~input:1.1~output:4.4~cached:0.275());("o4-mini-deep-research",p~input:2.0~output:8.0());("gpt-oss-120b",p~input:0.039~output:0.19());("gpt-oss-20b",p~input:0.03~output:0.14());("text-embedding-3-small",p~input:0.02~output:0.0());("text-embedding-3-large",p~input:0.13~output:0.0());("text-embedding-ada-002",p~input:0.1~output:0.0());("claude-fable-5",p~input:10.0~output:50.0~cached:1.0~cache_write_5m:12.5~cache_write_1h:20.0());("claude-opus-4-8",p~input:5.0~output:25.0~cached:0.5~cache_write_5m:6.25~cache_write_1h:10.0());("claude-opus-4-7",p~input:5.0~output:25.0~cached:0.5~cache_write_5m:6.25~cache_write_1h:10.0());(* List price; an introductory $2/$10 per MTok applies through 2026-08-31. *)("claude-sonnet-5",p~input:3.0~output:15.0~cached:0.3~cache_write_5m:3.75~cache_write_1h:6.0());("claude-opus-4-6",p~input:5.0~output:25.0~cached:0.5~cache_write_5m:6.25~cache_write_1h:10.0());("claude-sonnet-4-6",p~input:3.0~output:15.0~cached:0.3~cache_write_5m:3.75~cache_write_1h:6.0());("claude-opus-4-5-20251101",p~input:5.0~output:25.0~cached:0.5~cache_write_5m:6.25~cache_write_1h:10.0());("claude-opus-4-5",p~input:5.0~output:25.0~cached:0.5~cache_write_5m:6.25~cache_write_1h:10.0());("claude-sonnet-4-5-20250929",p~input:3.0~output:15.0~cached:0.3~cache_write_5m:3.75~cache_write_1h:6.0());("claude-sonnet-4-5",p~input:3.0~output:15.0~cached:0.3~cache_write_5m:3.75~cache_write_1h:6.0());("claude-haiku-4-5-20251001",p~input:1.0~output:5.0~cached:0.1~cache_write_5m:1.25~cache_write_1h:2.0());("claude-haiku-4-5",p~input:1.0~output:5.0~cached:0.1~cache_write_5m:1.25~cache_write_1h:2.0());("claude-opus-4-1-20250805",p~input:15.0~output:75.0~cached:1.5~cache_write_5m:18.75~cache_write_1h:30.0());("claude-opus-4-1",p~input:15.0~output:75.0~cached:1.5~cache_write_5m:18.75~cache_write_1h:30.0());("claude-sonnet-4-20250514",p~input:3.0~output:15.0~cached:0.3~cache_write_5m:3.75~cache_write_1h:6.0());("claude-sonnet-4-0",p~input:3.0~output:15.0~cached:0.3~cache_write_5m:3.75~cache_write_1h:6.0());("claude-opus-4-20250514",p~input:15.0~output:75.0~cached:1.5~cache_write_5m:18.75~cache_write_1h:30.0());("claude-opus-4-0",p~input:15.0~output:75.0~cached:1.5~cache_write_5m:18.75~cache_write_1h:30.0());("claude-3-5-sonnet-20241022",p~input:3.0~output:15.0~cached:0.3~cache_write_5m:3.75~cache_write_1h:6.0());("claude-3-5-sonnet-20240620",p~input:3.0~output:15.0~cached:0.3~cache_write_5m:3.75~cache_write_1h:6.0());("claude-3-5-haiku-20241022",p~input:0.8~output:4.0~cached:0.08~cache_write_5m:1.0~cache_write_1h:1.6());("claude-3-opus-20240229",p~input:15.0~output:75.0~cached:1.5~cache_write_5m:18.75~cache_write_1h:30.0());("claude-3-haiku-20240307",p~input:0.25~output:1.25~cached:0.03~cache_write_5m:0.3~cache_write_1h:0.5());("grok-4.5",p~input:2.0~output:6.0~cached:0.5());("grok-4.3",p~input:1.25~output:2.5~cached:0.2());("grok-4.20-0309-reasoning",p~input:1.25~output:2.5~cached:0.2());("grok-4.20-0309-non-reasoning",p~input:1.25~output:2.5~cached:0.2());("grok-4.20-multi-agent-0309",p~input:1.25~output:2.5~cached:0.2());("grok-4-1-fast-reasoning",p~input:0.2~output:0.5~cached:0.05());("grok-4-1-fast-non-reasoning",p~input:0.2~output:0.5~cached:0.05());("grok-4-fast-reasoning",p~input:0.2~output:0.5~cached:0.05());("grok-4-fast-non-reasoning",p~input:0.2~output:0.5~cached:0.05());("grok-4-0709",p~input:3.0~output:15.0~cached:0.75());("grok-4",p~input:3.0~output:15.0~cached:0.75());("grok-code-fast-1",p~input:0.2~output:1.5~cached:0.02());("grok-3",p~input:3.0~output:15.0~cached:0.75());("grok-3-mini",p~input:0.3~output:0.5~cached:0.07());("grok-2-vision-1212",p~input:2.0~output:10.0());("grok-imagine-image",p~input:0.0~output:0.0~per_image:0.02());("grok-imagine-image-pro",p~input:0.0~output:0.0~per_image:0.07());("grok-imagine-video",p~input:0.0~output:0.0~per_second:0.05());("grok-embedding-1",p~input:0.0~output:0.0());]letstarts_with~prefixvalue=letprefix_len=String.lengthprefixinString.lengthvalue>=prefix_len&&String.subvalue0prefix_len=prefixletcontainstextneedle=letneedle_len=String.lengthneedleinlettext_len=String.lengthtextinletrecloopindex=ifneedle_len=0thentrueelseifindex+needle_len>text_lenthenfalseelseifString.subtextindexneedle_len=needlethentrueelseloop(index+1)inloop0letfamily_modelmodel=letlower=String.lowercase_asciimodelinifstarts_with~prefix:"claude"lower&&(containslower"fable"||containslower"mythos")thenSome"claude-fable-5"elseifstarts_with~prefix:"claude"lower&&containslower"opus"thenSome"claude-opus-4-8"elseifstarts_with~prefix:"claude"lower&&containslower"sonnet"thenSome"claude-sonnet-5"elseifstarts_with~prefix:"claude"lower&&containslower"haiku"thenSome"claude-haiku-4-5"elseifstarts_with~prefix:"gpt-"lower&&containslower"-nano"thenSome"gpt-5.4-nano"elseifstarts_with~prefix:"gpt-"lower&&containslower"-mini"thenSome"gpt-5.4-mini"elseifstarts_with~prefix:"gpt-"lower&&containslower"-pro"thenSome"gpt-5.4-pro"elseifstarts_with~prefix:"gpt-"lower&&containslower"-codex"thenSome"gpt-5.2-codex"elseifstarts_with~prefix:"gpt-"lower&&containslower"o"thenSome"gpt-4o"elseifstarts_with~prefix:"gpt-"lowerthenSome"gpt-5.4"elseifstarts_with~prefix:"o"lower&&containslower"-mini"thenSome"o4-mini"elseifstarts_with~prefix:"o"lower&&containslower"-pro"thenSome"o3-pro"elseifstarts_with~prefix:"o"lowerthenSome"o3"elseifstarts_with~prefix:"grok-4.20"lowerthenSome"grok-4.20-0309-reasoning"elseifstarts_with~prefix:"grok-"lower&&containslower"fast-reasoning"thenSome"grok-4-1-fast-reasoning"elseifstarts_with~prefix:"grok-"lower&&containslower"fast-non-reasoning"thenSome"grok-4-1-fast-non-reasoning"elseifstarts_with~prefix:"grok-"lower&&containslower"mini"thenSome"grok-3-mini"elseifstarts_with~prefix:"grok-"lower&&containslower"code"thenSome"grok-code-fast-1"elseifstarts_with~prefix:"grok-imagine-image-pro"lowerthenSome"grok-imagine-image-pro"elseifstarts_with~prefix:"grok-imagine-image"lowerthenSome"grok-imagine-image"elseifstarts_with~prefix:"grok-imagine-video"lowerthenSome"grok-imagine-video"elseifstarts_with~prefix:"grok-"lowerthenSome"grok-4.5"elseifstarts_with~prefix:"chatgpt"lowerthenSome"o1-pro"elseNoneletprovider_max_modelmodel=letlower=String.lowercase_asciimodelinifstarts_with~prefix:"claude"lowerthenSome"claude-opus-4-1"elseifstarts_with~prefix:"gpt-"lower||starts_with~prefix:"chatgpt"lower||starts_with~prefix:"o"lowerthenSome"o1-pro"elseifstarts_with~prefix:"grok"lowerthenSome"grok-4-0709"elseNoneletget?fallbackmodel=matchList.assoc_optmodelallwith|Somepricing->Somepricing|None->(matchOption.bind(family_modelmodel)(funmodel->List.assoc_optmodelall)with|Some_aspricing->pricing|None->(matchOption.bind(provider_max_modelmodel)(funmodel->List.assoc_optmodelall)with|Some_aspricing->pricing|None->fallback))lethasmodel=Option.is_some(List.assoc_optmodelall)