💰 feat: Add gpt-5.3 context window and pricing (#12049)

* 💰 feat: Add gpt-5.3 context window and pricing

* 💰 feat: Add OpenAI cached input pricing and `gpt-5.2-pro` model

    - Add cached input pricing (write/read) for gpt-4o, gpt-4.1, gpt-5.x,
      o1, o3, o4-mini models with correct per-family discount tiers
    - Add gpt-5.2-pro pricing ($21/$168), context window, and max output
    - Pro models (gpt-5-pro, gpt-5.2-pro) correctly excluded from cache
      pricing as OpenAI does not support caching for these

* 🔍 fix: Address review findings for OpenAI pricing

- Add o1-preview to cacheTokenValues (50% discount, same as o1)
- Fix comment to enumerate all models per discount tier
- Add cache tests for dated variants (gpt-4o-2024-08-06, etc.)
- Add gpt-5-mini/gpt-5-nano to 10% ratio invariant test
- Replace forEach with for...of in new test code
- Fix inconsistent test description phrasing
- Add gpt-5.3-preview to context window tests
This commit is contained in:
Danny Avila 2026-03-03 20:44:05 -05:00 committed by GitHub
parent 474001c140
commit d3622844ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 156 additions and 2 deletions

View file

@ -200,6 +200,20 @@ describe('getModelMaxTokens', () => {
);
});
test('should return correct tokens for gpt-5.3 matches', () => {
expect(getModelMaxTokens('gpt-5.3')).toBe(maxTokensMap[EModelEndpoint.openAI]['gpt-5.3']);
expect(getModelMaxTokens('gpt-5.3-codex')).toBe(maxTokensMap[EModelEndpoint.openAI]['gpt-5.3']);
expect(getModelMaxTokens('openai/gpt-5.3')).toBe(
maxTokensMap[EModelEndpoint.openAI]['gpt-5.3'],
);
expect(getModelMaxTokens('gpt-5.3-2025-03-01')).toBe(
maxTokensMap[EModelEndpoint.openAI]['gpt-5.3'],
);
expect(getModelMaxTokens('gpt-5.3-preview')).toBe(
maxTokensMap[EModelEndpoint.openAI]['gpt-5.3'],
);
});
test('should return correct tokens for Anthropic models', () => {
const models = [
'claude-2.1',
@ -492,7 +506,17 @@ describe('getModelMaxTokens', () => {
test('should return correct max output tokens for GPT-5 models', () => {
const { getModelMaxOutputTokens } = require('@librechat/api');
['gpt-5', 'gpt-5-mini', 'gpt-5-nano', 'gpt-5-pro'].forEach((model) => {
const gpt5Models = [
'gpt-5',
'gpt-5.1',
'gpt-5.2',
'gpt-5.3',
'gpt-5-mini',
'gpt-5-nano',
'gpt-5-pro',
'gpt-5.2-pro',
];
for (const model of gpt5Models) {
expect(getModelMaxOutputTokens(model)).toBe(maxOutputTokensMap[EModelEndpoint.openAI][model]);
expect(getModelMaxOutputTokens(model, EModelEndpoint.openAI)).toBe(
maxOutputTokensMap[EModelEndpoint.openAI][model],
@ -500,7 +524,7 @@ describe('getModelMaxTokens', () => {
expect(getModelMaxOutputTokens(model, EModelEndpoint.azureOpenAI)).toBe(
maxOutputTokensMap[EModelEndpoint.azureOpenAI][model],
);
});
}
});
test('should return correct max output tokens for GPT-OSS models', () => {
@ -612,6 +636,12 @@ describe('matchModelName', () => {
expect(matchModelName('gpt-5-pro-2025-01-30-0130')).toBe('gpt-5-pro');
});
it('should return the closest matching key for gpt-5.3 matches', () => {
expect(matchModelName('openai/gpt-5.3')).toBe('gpt-5.3');
expect(matchModelName('gpt-5.3-codex')).toBe('gpt-5.3');
expect(matchModelName('gpt-5.3-2025-03-01')).toBe('gpt-5.3');
});
// Tests for Google models
it('should return the exact model name if it exists in maxTokensMap - Google models', () => {
expect(matchModelName('text-bison-32k', EModelEndpoint.google)).toBe('text-bison-32k');