Codex opens GPT-6.1 Terra with a 500k default window, so subscription
requests routinely pass the 272k API long-context threshold. Apply the
existing GPT-6.1 Sol rule: OAuth and setup-token requests whose final
upstream model is Terra skip the model surcharge, while API keys keep
the published 2x input/cache and 1.5x output rates. Also label Terra's
fallback prices with their own release date.
GPT-6.1 Terra publishes none through max; minimal is not on its scale.
Recognize the -minimal spelling so the alias still resolves to Terra,
and reject minimal on the Chat, Messages and Responses compatibility
paths with the same 400 Sol uses for its unsupported levels. none stays
valid for Terra, and Sol keeps its stricter low-through-max checks.
Compatibility requests mapped to Terra also did not receive the derived
prompt_cache_key that other GPT-6 Responses models get, so Chat and
Messages traffic lost its stable cache identity. Include Terra there.
The generated Terra entry copied the API model page into the Codex
catalog: it offered none, omitted ultra, defaulted to medium and fell
back to a 272k window and the GPT-5.5 prompt. Codex publishes a separate
descriptor (openai/codex 126a0ee92ed2, models.json): low by default, low
through ultra, a 500k/872k window, Fast as the only extra tier and its
own instructions. A ChatGPT Plus account's live /backend-api/codex/models
response reports the same reasoning, window and tier values.
Bundle that descriptor like GPT-6.1 Sol, take Terra's base instructions
from it, and give official accounts the same route defaults: API-key
clients stay on full Responses, OAuth keeps Responses Lite and code mode.
Account-supplied manifests remain authoritative, and API requests keep
none through max. The model list now records the 2026-10-26 release
time instead of a 2024 placeholder.
Multipart image uploads were read through io.LimitReader(part, 20MB), so any
image larger than 20MB was silently cut short. The OAuth path (and the Grok
media path) then base64-encoded the truncated bytes and sent them upstream,
which answered 400 invalid_image_file. The API key path forwards the raw
multipart body and was not affected, so the same request worked or failed
depending on which account served it.
- Raise the per-part limit to 50MB, OpenAI's documented per-image limit for
GPT image edits, and return 400 when a part exceeds it.
- Read Grok media parts whole; the body is already bounded by the gateway
request body limit.
- Log each upload's content type and size on the images routing line.
calculatePerRequestCost falls back to context-based tiers when the size
tier misses; dropping Tokens made those tiers never match and settled
images at $0 regardless of the image_count_billing switch.
- Require per-request/image mode for group image pricing so token-mode
group cards no longer settle images at $0.
- Force per-image billing for channel token pricing when the group switch
is enabled, matching the OpenAI pipeline.
- Add an ImageEndpoint marker so the switch only applies to dedicated
image endpoints; mixed Responses/Chat/WS requests keep token billing.
- Only fall back to one image when the switch is enabled, preserving the
previous count semantics when it is off.
- Validate image_count_billing in GroupService and gate the admin
checkbox on allow_image_generation.
- Bump the API key auth snapshot version for the new group field.
Use strconv to reject pagination values outside the native int range,
reuse PaginationParams.Offset for API key slices, and derive test bounds
from math.MaxInt. Cover parsing, response metadata, strict handlers, and
in-memory pagination at the arithmetic boundaries.
A page such as 9223372036854775807 passed every pagination check, so
(page-1)*pageSize wrapped around. With an even page size the offset
became negative and PostgreSQL rejected the query with "OFFSET must not
be negative"; paths that slice in memory (paginateSlice, balance history
merge) panicked with a negative slice bound. Both surfaced as HTTP 500 on
list endpoints such as /api/v1/admin/users, /api/v1/usage, /api/v1/keys
and /api/v1/admin/payment/orders.
- PaginationParams.Offset saturates Page at MaxInt/limit, so offset and
offset+limit both stay within int.
- ParsePagination clamps page the same way, which covers the repositories
that compute (page-1)*pageSize themselves.
- The prompt audit event list and the OpenAI token stats filter parse page
on their own; they now reject an overflowing page with 400, like other
invalid pagination input there.