LibreChat/api/utils
Danny Avila b753da163e
🤖 feat: Add GPT-5.6 (Sol/Terra/Luna) OpenAI Models (#14206)
*  feat: Add GPT-5.6 (Sol/Terra/Luna) OpenAI models

Adds the GPT-5.6 family (GA 2026-07-09) across the context, output,
pricing, cache, premium, and default-model maps, mirroring gpt-5.5.

- gpt-5.6 (Sol alias), gpt-5.6-terra, gpt-5.6-luna
- 1.05M context / 128K output for all tiers
- Standard + long-context (>272K input) tiered pricing and cache rates

* 🐛 fix: Bill GPT-5.6 cache writes at documented 1.25x input surcharge

OpenAI prices GPT-5.6 cache writes above the base input rate (Sol $6.25,
Terra $3.125, Luna $1.25 per 1M vs $5/$2.50/$1 input). Correct the
cacheTokenValues write rates so explicit prompt-caching usage is billed
and reported accurately, and lock the surcharge with a test.

*  feat: Expose GPT-5.6 max reasoning effort + long-context cache premium

Folds in the two deferred Codex findings:

1. Add `max` to the OpenAI `ReasoningEffort` enum and the reasoning_effort
   parameter options/labels so GPT-5.6 (Sol/Terra/Luna) can request its
   documented highest reasoning setting. Backend passthrough and zod
   validation pick it up via the nativeEnum schema.

2. Apply the long-context (>272K input) premium to cache tokens. Adds
   `premiumCacheTokenValues` + `getPremiumCacheRate`, threads
   `inputTokenCount` into `getCacheMultiplier`, and wires it through both
   structured-spend paths. Covers the gpt-5.4/5.5/5.6 family whose cache
   write/read previously stayed at flat base rates on long-context calls.

* 🐛 fix: Bill GPT-5.6 cache writes + map max effort for OpenRouter Claude

Addresses Codex round-3 findings:

1. (P1) splitUsage only read `cache_creation`/`cache_creation_input_tokens`,
   so OpenAI GPT-5.6's `cache_write_tokens` fell into inputOnly and billed at
   the input rate instead of the 1.25x write rate. Extend UsageMetadata and
   single-source the cache-creation read to also recognize `cache_write_tokens`
   (nested and top-level).

2. (P2) `max` was exposed via OpenRouter (spreads OpenAI settings) but the
   adaptive-Claude verbosity map had no `max`, so it was silently dropped. Map
   max -> 'max' verbosity.

* 🐛 fix: Forward GPT-5.6 cache_write_tokens into emitted usage

Local Codex review (P1): the cache-write fix reached balance billing
(splitUsage/getCacheCreationTokens) but not the emitted-usage pipeline.
ModelEndHandler built the emitted event's cache_creation from only
cache_creation/cache_creation_input_tokens, so GPT-5.6 cache_write_tokens
were dropped and aggregateEmittedUsage classified them as ordinary input —
displayed/persisted cost undercounted and disagreed with the balance charge.
Fold cache_write_tokens (nested + top-level) into the emitted cache_creation.
2026-07-12 07:52:59 -04:00
..
logger.js 🗂️ feat: Allow Disabling File Log Transports (#13215) 2026-05-20 23:16:56 -04:00
LoggingSystem.js feat: Logins log for Fail2Ban (#986) 2023-09-24 12:18:10 -04:00
tokens.spec.js 🤖 feat: Add GPT-5.6 (Sol/Terra/Luna) OpenAI Models (#14206) 2026-07-12 07:52:59 -04:00