Skip to content

Document promptCacheKey opt-in for compatible custom openai-chat providers #2536

Description

@wssfk12138

Documentation problem type

Missing documentation

Documentation location

https://opencodex.me/reference/configuration/providers/

What is wrong or missing?

The custom openai-chat provider reference does not document the per-provider promptCacheKey capability flag or explain that it controls forwarding of an inbound prompt_cache_key to the upstream Chat Completions request.

The conditional forwarding added in #217 and #224 works correctly. The missing documentation makes the opt-in difficult to discover, so a compatible custom provider may silently receive no stable cache-affinity key even though Codex supplies one.

This had a measurable effect with an anonymous OpenAI-compatible custom provider on OpenCodex 2.31.0. Before the opt-in, 12 natural requests contained 976,572 input tokens and 9,216 cached input tokens, an aggregate cache ratio of 0.94%, with 10 zero-cache requests. After adding only promptCacheKey: true and restarting OpenCodex, 28 natural requests contained 2,327,714 input tokens and 1,943,552 cached input tokens, an aggregate cache ratio of 83.50%, with no HTTP errors. Excluding the first cold request in each of two conversations, the aggregate ratios were 95.66% and 86.89%, with no subsequent zero-cache requests.

API-key rotation, proxy retries or duplicate sends, usage telemetry mismatch, helper routing, and Codex local-memory toggling were checked and did not explain the difference.

What should the documentation explain instead?

The custom-provider reference should explain that:

  • promptCacheKey: true is an explicit compatibility opt-in for openai-chat providers that accept OpenAI's prompt_cache_key field.
  • When enabled, OpenCodex forwards the stable key supplied by the client; when absent or false, it omits the field.
  • The option is deliberately not a global default because strict OpenAI-compatible gateways may reject unknown fields with HTTP 400.
  • Users should enable it only for a provider with confirmed support, preserve the rest of the provider configuration, restart or reload OpenCodex as required, and remove the option if the upstream reports an unknown-field error.
  • Cache validation should distinguish the first cold request from later requests in the same conversation.

Suggested wording or example

For a custom Chat Completions provider that explicitly supports prompt_cache_key:

{
  "providers": {
    "example-compatible-provider": {
      "adapter": "openai-chat",
      "promptCacheKey": true
    }
  }
}

promptCacheKey is disabled by default for custom providers. Enable it only when the upstream accepts prompt_cache_key; otherwise a strict gateway may return HTTP 400. Existing baseUrl, authentication, model, and key-pool fields should remain unchanged.

Additional context or attachments

Checks

  • I searched existing documentation issues.
  • No secrets or personal information are included.

Activity

added
providerProvider adapters, OpenAI-compat presets, upstream API quirks
on Aug 25, 2026

github-actions commented on Aug 25, 2026

@github-actions
Contributor

Issue reopened

The report now contains the information required by the automated check. Thanks for updating it.

lidge-jun commented on Aug 25, 2026

@lidge-jun
Owner

리뷰 · 우선순위 54 / 80

설명: 이 이슈는 맞춤 openai-chat 제공자의 promptCacheKey 켜는 법을 문서에 적어 달라는 요청이다. 작성자는 wssfk12138 이다. 라벨은 documentation, provider 다. 지금 CURRENT dev HEAD 는 98ed186 이다. 이번 시간에 SHA 는 안 움직였다. 구현 풀은 아직 없다. 이슈를 연다. 닫지 말 것. 라벨은 바꾸지 말 것. 동작을 바꾸라는 이슈가 아니다.

코드는 이미 있다. src/types/provider.ts 432-437줄이 그 칸을 적는다. 기본은 끄고, 업스트림이 prompt_cache_key 를 받을 때만 켜라고 적혀 있다. src/adapters/openai-chat.ts 143-145줄과 1456-1458줄이 그 칸이 참일 때만 들어온 키를 그대로 보낸다. 키가 없으면 칸을 안 넣는다. src/providers/registry.ts 는 키미 프리셋에 참을 심는다. 이슈가 가리킨 217 과 224 의 동작과 맞다. 전역 기본을 켜라는 뜻이 아니다. 그 말은 이슈에도 있다.

빠진 곳은 문서다. docs-site/src/content/docs/reference/configuration/providers.md 의 제공자 칸 표 65-133줄에 promptCacheKey 줄이 없다. 이슈가 적은 https://opencodex.me/reference/configuration/providers/ 가 그 파일이다. docs-site/src/content/docs/guides/providers.md 124-129줄은 키미 프리셋만 말하고, 다른 제공자는 기본 거절이라고만 한다. 맞춤 openai-chat 에 참을 넣는 예는 없다. 그래서 호환 게이트웨이를 쓰는 사람은 코드 주석을 읽지 못하면 이 칸을 못 찾는다. 이슈의 측정은 참고만 한다. 그 숫자를 재현하지는 않았다.

고칠 곳은 그 표에 칸 한 줄과, 가이드에 맞춤 제공자 예 하나다. 기본값을 바꾸지 말 것. 어댑터 동작을 바꾸지 말 것. 키미 프리셋도 그대로 둔다. types.ts 와 config.ts 가르기와는 무관하다. 프리뷰 배포가 아니다. 2463 2464 2465 를 이 문서로 닫지 말 것. 별칭 파일은 없다.

docs-site/src/content/docs/reference/configuration/providers.md 65-133줄 HEAD - OcxProviderConfig 표에 promptCacheKey 칸이 없다
docs-site/src/content/docs/guides/providers.md 124-129줄 HEAD - 키미 프리셋만 적고 맞춤 제공자 켜는 예가 없다
src/types/provider.ts 432-437줄 HEAD - 코드 주석에는 이미 적혀 있다. 문서만 뒤처진다
src/adapters/openai-chat.ts 143-145줄 HEAD - 칸이 참일 때만 전달한다. 동작 변경이 아니다
src/adapters/openai-chat.ts 1456-1458줄 HEAD - 번역 경로도 같다

메인테이너의 판단이 필요한 지점

  • 이 이슈를 지금 닫을지. 닫지 말 것. 문서 풀이 아직 없다
  • 기본값을 켤지. 켜지 말 것. 이슈도 문서만 요청한다. 엄격한 게이트웨이는 400 을 낸다
  • 가이드만 고치고 참조 표를 건너뛸지. 건너뛰지 말 것. 이슈가 적은 페이지가 그 표다
  • 키미 설명을 지울지. 지우지 말 것. 맞춤 제공자 예를 옆에 더하면 된다

너의 추천
이 이슈는 연다. 참조 표에 promptCacheKey 줄을 넣고, 가이드에 맞춤 openai-chat 예 하나를 더하는 문서 풀을 기다린다. 기본값과 어댑터는 건드리지 말 것. 내가 머지하지 않는다. 라벨은 그대로 둔다. 프리뷰 배포가 아니다.

이 댓글은 grok-bot이 작성했습니다

lidge-jun commented on Aug 25, 2026

@lidge-jun
Owner

Landed via #2625 at 6f3b5af

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationlanded-via-maintainerOriginal PR closed after landing via a maintainer merge trainproviderProvider adapters, OpenAI-compat presets, upstream API quirks

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions