@@ -25,8 +25,14 @@ describe('getValueKey', () => {
2525 expect ( getValueKey ( 'gpt-4-some-other-info' ) ) . toBe ( '8k' ) ;
2626 } ) ;
2727
28- it ( 'should return undefined for model names that do not match any known patterns' , ( ) => {
29- expect ( getValueKey ( 'gpt-5-some-other-info' ) ) . toBeUndefined ( ) ;
28+ it ( 'should return "gpt-5" for model name containing "gpt-5"' , ( ) => {
29+ expect ( getValueKey ( 'gpt-5-some-other-info' ) ) . toBe ( 'gpt-5' ) ;
30+ expect ( getValueKey ( 'gpt-5-2025-01-30' ) ) . toBe ( 'gpt-5' ) ;
31+ expect ( getValueKey ( 'gpt-5-2025-01-30-0130' ) ) . toBe ( 'gpt-5' ) ;
32+ expect ( getValueKey ( 'openai/gpt-5' ) ) . toBe ( 'gpt-5' ) ;
33+ expect ( getValueKey ( 'openai/gpt-5-2025-01-30' ) ) . toBe ( 'gpt-5' ) ;
34+ expect ( getValueKey ( 'gpt-5-turbo' ) ) . toBe ( 'gpt-5' ) ;
35+ expect ( getValueKey ( 'gpt-5-0130' ) ) . toBe ( 'gpt-5' ) ;
3036 } ) ;
3137
3238 it ( 'should return "gpt-3.5-turbo-1106" for model name containing "gpt-3.5-turbo-1106"' , ( ) => {
@@ -84,6 +90,29 @@ describe('getValueKey', () => {
8490 expect ( getValueKey ( 'gpt-4.1-nano-0125' ) ) . toBe ( 'gpt-4.1-nano' ) ;
8591 } ) ;
8692
93+ it ( 'should return "gpt-5" for model type of "gpt-5"' , ( ) => {
94+ expect ( getValueKey ( 'gpt-5-2025-01-30' ) ) . toBe ( 'gpt-5' ) ;
95+ expect ( getValueKey ( 'gpt-5-2025-01-30-0130' ) ) . toBe ( 'gpt-5' ) ;
96+ expect ( getValueKey ( 'openai/gpt-5' ) ) . toBe ( 'gpt-5' ) ;
97+ expect ( getValueKey ( 'openai/gpt-5-2025-01-30' ) ) . toBe ( 'gpt-5' ) ;
98+ expect ( getValueKey ( 'gpt-5-turbo' ) ) . toBe ( 'gpt-5' ) ;
99+ expect ( getValueKey ( 'gpt-5-0130' ) ) . toBe ( 'gpt-5' ) ;
100+ } ) ;
101+
102+ it ( 'should return "gpt-5-mini" for model type of "gpt-5-mini"' , ( ) => {
103+ expect ( getValueKey ( 'gpt-5-mini-2025-01-30' ) ) . toBe ( 'gpt-5-mini' ) ;
104+ expect ( getValueKey ( 'openai/gpt-5-mini' ) ) . toBe ( 'gpt-5-mini' ) ;
105+ expect ( getValueKey ( 'gpt-5-mini-0130' ) ) . toBe ( 'gpt-5-mini' ) ;
106+ expect ( getValueKey ( 'gpt-5-mini-2025-01-30-0130' ) ) . toBe ( 'gpt-5-mini' ) ;
107+ } ) ;
108+
109+ it ( 'should return "gpt-5-nano" for model type of "gpt-5-nano"' , ( ) => {
110+ expect ( getValueKey ( 'gpt-5-nano-2025-01-30' ) ) . toBe ( 'gpt-5-nano' ) ;
111+ expect ( getValueKey ( 'openai/gpt-5-nano' ) ) . toBe ( 'gpt-5-nano' ) ;
112+ expect ( getValueKey ( 'gpt-5-nano-0130' ) ) . toBe ( 'gpt-5-nano' ) ;
113+ expect ( getValueKey ( 'gpt-5-nano-2025-01-30-0130' ) ) . toBe ( 'gpt-5-nano' ) ;
114+ } ) ;
115+
87116 it ( 'should return "gpt-4o" for model type of "gpt-4o"' , ( ) => {
88117 expect ( getValueKey ( 'gpt-4o-2024-08-06' ) ) . toBe ( 'gpt-4o' ) ;
89118 expect ( getValueKey ( 'gpt-4o-2024-08-06-0718' ) ) . toBe ( 'gpt-4o' ) ;
@@ -207,6 +236,48 @@ describe('getMultiplier', () => {
207236 ) ;
208237 } ) ;
209238
239+ it ( 'should return the correct multiplier for gpt-5' , ( ) => {
240+ const valueKey = getValueKey ( 'gpt-5-2025-01-30' ) ;
241+ expect ( getMultiplier ( { valueKey, tokenType : 'prompt' } ) ) . toBe ( tokenValues [ 'gpt-5' ] . prompt ) ;
242+ expect ( getMultiplier ( { valueKey, tokenType : 'completion' } ) ) . toBe (
243+ tokenValues [ 'gpt-5' ] . completion ,
244+ ) ;
245+ expect ( getMultiplier ( { model : 'gpt-5-preview' , tokenType : 'prompt' } ) ) . toBe (
246+ tokenValues [ 'gpt-5' ] . prompt ,
247+ ) ;
248+ expect ( getMultiplier ( { model : 'openai/gpt-5' , tokenType : 'completion' } ) ) . toBe (
249+ tokenValues [ 'gpt-5' ] . completion ,
250+ ) ;
251+ } ) ;
252+
253+ it ( 'should return the correct multiplier for gpt-5-mini' , ( ) => {
254+ const valueKey = getValueKey ( 'gpt-5-mini-2025-01-30' ) ;
255+ expect ( getMultiplier ( { valueKey, tokenType : 'prompt' } ) ) . toBe ( tokenValues [ 'gpt-5-mini' ] . prompt ) ;
256+ expect ( getMultiplier ( { valueKey, tokenType : 'completion' } ) ) . toBe (
257+ tokenValues [ 'gpt-5-mini' ] . completion ,
258+ ) ;
259+ expect ( getMultiplier ( { model : 'gpt-5-mini-preview' , tokenType : 'prompt' } ) ) . toBe (
260+ tokenValues [ 'gpt-5-mini' ] . prompt ,
261+ ) ;
262+ expect ( getMultiplier ( { model : 'openai/gpt-5-mini' , tokenType : 'completion' } ) ) . toBe (
263+ tokenValues [ 'gpt-5-mini' ] . completion ,
264+ ) ;
265+ } ) ;
266+
267+ it ( 'should return the correct multiplier for gpt-5-nano' , ( ) => {
268+ const valueKey = getValueKey ( 'gpt-5-nano-2025-01-30' ) ;
269+ expect ( getMultiplier ( { valueKey, tokenType : 'prompt' } ) ) . toBe ( tokenValues [ 'gpt-5-nano' ] . prompt ) ;
270+ expect ( getMultiplier ( { valueKey, tokenType : 'completion' } ) ) . toBe (
271+ tokenValues [ 'gpt-5-nano' ] . completion ,
272+ ) ;
273+ expect ( getMultiplier ( { model : 'gpt-5-nano-preview' , tokenType : 'prompt' } ) ) . toBe (
274+ tokenValues [ 'gpt-5-nano' ] . prompt ,
275+ ) ;
276+ expect ( getMultiplier ( { model : 'openai/gpt-5-nano' , tokenType : 'completion' } ) ) . toBe (
277+ tokenValues [ 'gpt-5-nano' ] . completion ,
278+ ) ;
279+ } ) ;
280+
210281 it ( 'should return the correct multiplier for gpt-4o' , ( ) => {
211282 const valueKey = getValueKey ( 'gpt-4o-2024-08-06' ) ;
212283 expect ( getMultiplier ( { valueKey, tokenType : 'prompt' } ) ) . toBe ( tokenValues [ 'gpt-4o' ] . prompt ) ;
@@ -307,7 +378,7 @@ describe('getMultiplier', () => {
307378 } ) ;
308379
309380 it ( 'should return defaultRate if derived valueKey does not match any known patterns' , ( ) => {
310- expect ( getMultiplier ( { tokenType : 'prompt' , model : 'gpt-5 -some-other-info' } ) ) . toBe (
381+ expect ( getMultiplier ( { tokenType : 'prompt' , model : 'gpt-10 -some-other-info' } ) ) . toBe (
311382 defaultRate ,
312383 ) ;
313384 } ) ;
0 commit comments