Skip to content

feat(api): warmup api - #506

Closed
huzky-v wants to merge 1 commit into
Soju06:mainfrom
huzky-v:feat/warmup-api
Closed

huzky-v wants to merge 1 commit into
Soju06:mainfrom
huzky-v:feat/warmup-api

Conversation

@huzky-v

@huzky-v huzky-v commented Apr 27, 2026 •

Copy link
Copy Markdown
Collaborator

Purpose

Although there is pending PR (#438) for the Warm up mechanism, I have an another approach to the warm-up implementation, that I am planning to integrate into my Opencode plugin workflow.

This PR is to create an API that warmup the accounts linked to the codex-lb API which

  • Does not require an automated system on server side
  • Warmup when the session actually start (The session starts when you called the API), avoid potential session window waste
  • Provide a more flexible warmup strategy, window frame and scope

Specification

POST /v1/warmup
Authentication: Bearer {codex-lb-key}

Body:

{
  "mode": "<mode>"
}

or
Authentication: Bearer {codex-lb-key}
POST /v1/warmup/${mode}
without a body

mode:

  • normal: send warmup request for accounts that has 5h window and the 5h usage remaining is 100%
  • strict: send warmup request only if all accounts have 5h window and the 5h usage remaining is 100%, otherwise will not send the request
  • force: Force warming up all accounts in the account pool for the API key unconditionally

The model used is defaulted to gpt-5.4-mini, which could be changed on the env variable: CODEX_LB_WARMUP_MODEL

UI change

The warmup request will now tagged on the UI.
螢幕截圖 2026-04-27 22 10 13

@huzky-v
huzky-v force-pushed the feat/warmup-api branch 2 times, most recently from 8cbcf49 to 3140506 Compare April 28, 2026 08:42
@huzky-v

huzky-v commented Apr 28, 2026

Copy link
Copy Markdown
Collaborator Author

@Soju06 It is ready to review. Is there any suggestions on the feature?

@huzky-v
huzky-v requested a review from Soju06 April 29, 2026 04:43
@huzky-v
huzky-v force-pushed the feat/warmup-api branch from 8e618e7 to 6973869 Compare May 14, 2026 07:10
@Komzpa

Komzpa commented May 16, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 697386991f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1971 to +1974
configured_model = get_settings().warmup_model
effective_model = api_key.enforced_model if api_key and api_key.enforced_model else configured_model
validate_model_access(api_key, effective_model)
filtered_headers = filter_inbound_headers(headers)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Enforce API key usage limits on warmup submissions

warmup() validates only model access and then sends upstream requests for every target account, but it never acquires/finalizes an API-key usage reservation like the normal /v1/responses paths do. In practice, a key that has already hit request/token limits can still call /v1/warmup (especially force) to generate additional upstream traffic, which can drain shared account quota without being blocked by key limits; this commit also tags those calls as request_kind="warmup" and excludes them from usage aggregates, so operators won’t see that spend in key-level totals.

Useful? React with 👍 / 👎.

@Komzpa Komzpa added 🤖 codex: needs work [@codex review] raised an issue 🤖 codex: ok [@codex review] says no issues found. and removed 🤖 codex: needs work [@codex review] raised an issue 🤖 codex: ok [@codex review] says no issues found. labels May 16, 2026
@jamesx0416

Copy link
Copy Markdown
Contributor

Why tf does github not have a view all button?

@Soju06

Soju06 commented May 21, 2026

Copy link
Copy Markdown
Owner

Maintainer cleanup: closing this as stale / no longer merge-ready against the current main.

This PR has been open across substantial main-branch churn and is currently carrying at least one stale signal (conflicts/blocked or failing checks, outstanding codex: needs work, draft/old branch state, or overlap with newer/current implementation). Keeping it open is making the PR queue harder to reason about.

If the change is still needed, please open a fresh, focused PR rebased on current main with green CI and a clean Codex review.

@Soju06 Soju06 closed this May 21, 2026
@Komzpa Komzpa added needs rebase Needs rebase or conflict repair against current main stale No response from reporter; scheduled for close labels May 21, 2026
@Komzpa

Komzpa commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Revived on a maintainer-owned branch as #768 because this PR head has maintainerCanModify=false and cannot be updated here. Keeping credit to the original implementation in the replacement PR.

@Komzpa Komzpa added superseded Replaced by another PR, issue track, or merged implementation and removed 🤖 codex: needs work [@codex review] raised an issue needs rebase Needs rebase or conflict repair against current main labels May 21, 2026
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label May 21, 2026
@huzky-v
huzky-v deleted the feat/warmup-api branch May 21, 2026 14:33
@Komzpa Komzpa removed the 🤖 codex: needs work [@codex review] raised an issue label May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale No response from reporter; scheduled for close superseded Replaced by another PR, issue track, or merged implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants