Skip to content

feat(providers): add TokenLab API-key preset - #6221

Merged
lidge-jun merged 3 commits into
lidge-jun:devfrom
hedging8563:codex/tokenlab-provider
Sep 29, 2026
Merged

lidge-jun merged 3 commits into
lidge-jun:devfrom
hedging8563:codex/tokenlab-provider

Conversation

@hedging8563

@hedging8563 hedging8563 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add TokenLab as an ordinary API-key provider in the dashboard, CLI initializer and ocx provider add tokenlab. The preset reuses openai-chat at https://api.tokenlab.sh/v1; it adds no sponsor status, ranking preference, OAuth flow or adapter.

Discovery sends the configured Bearer key to /v1/models?category=chat and retains only rows with an explicit chat category and tool-use capability. The authenticated live catalog takes precedence over the seeded gpt-5.6-terra model, so a key that cannot access that model does not acquire it through the fallback. Existing same-named custom destinations remain unchanged. The provider guide documents setup, discovery scope and service terms.

Provider evidence (checked 2026-09-29)

  • API: Chat Completions quickstart, model discovery, and default model detail.
  • Operator: TOKENLAB AI INC., identified in the TokenLab website footer. Terms of Service and Privacy Policy are public.
  • Affiliation and maintenance: this is a submission by the TokenLab operator. GitHub @hedging8563 owns ongoing preset maintenance; integration regressions can be reported in this repository, and service issues to support@tokenlab.sh.
  • Routing/resale authorization: supporting authorization evidence has not been attached to this PR. The public API contract and company identity are not presented as proof of third-party authorization. This PR remains a draft pending that admission requirement; it makes no claim of upstream endorsement or direct partnership.

Verification

  • bun test tests/providers/tokenlab-provider.test.ts tests/providers/provider-registry-parity.test.ts tests/providers/provider-model-discovery-contract.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts — 131 passed, 0 failed. Covers entry-point derivation, upstream model identity, canonical/renamed/custom destinations, mixed-catalog filtering, per-key catalog precedence, and rejected/unavailable key checks.
  • bun test tests/providers/provider-static-model-discovery.test.ts tests/providers/sponsor-presets.test.ts tests/ci-workflows/file-size-ratchet.test.ts — 20 passed, 0 failed.
  • bun test tests/providers/tokenlab-provider.test.ts — 6 passed after aligning the dashboard link with TokenLab's published /dashboard/api?tab=keys URL.
  • bun run typecheck, bun run privacy:scan, bun run structure:check — passed.
  • cd docs-site && bun install --frozen-lockfile && bun run build — passed; 537 pages built and 73,657 internal links checked. The final documentation build was repeated after correcting the dashboard link.
  • Read-only live discovery using the actual registry filter admitted 112 of 142 public chat rows. All 112 model-detail responses declared openai_chat_completions. An intentionally invalid Bearer key returned HTTP 401 / invalid_api_key; anonymous discovery returned HTTP 200. This verifies the distinction between public discovery and supplied-key validation.
  • Live verification on 2026-09-29 at 05:45 UTC against this exact head used a real TokenLab test API key with the registry seed, routeModel, and the production createOpenAIChatAdapter().buildRequest/parseStream path. Authenticated discovery returned HTTP 200: 142 chat rows, 112 admitted tool-capable rows, with gpt-5.6-terra present. Two real streamed requests completed the tool round trip: the model emitted add({a:19,b:23}), the local harness returned 42 under the same tool-call ID, and the model answered 42. Both responses were HTTP 200 / text/event-stream, ended with [DONE], and parsed to one successful terminal event. Finish reasons were tool_calls then stop; reported usage totaled 350 input and 26 output tokens. Each request was capped at 1,024 output tokens with no retries.
  • Live coverage is one model, one test key, and the production adapter path; it does not cover a full proxy/Codex UI session or a live restricted-key catalog matrix. Restricted-key filtering remains fixture-tested. Full-suite execution is left to maintainer-approved CI: the change is limited to provider metadata and documentation, and the focused provider/discovery consumers above were run instead of the repository-wide suite. Cross-platform CI has not yet run on this fork PR.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • New Features
    • Added TokenLab as a provider option, with live discovery of supported chat models and gpt-5.6-terra as the default.
    • The built-in provider registry now includes 100 presets, including 83 key-based presets.
  • Documentation
    • Updated setup and provider guides across supported languages to reflect the expanded preset catalog and document TokenLab.

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 2fb321d7-6fba-4bd2-9fd2-576132843bf2

📥 Commits

Reviewing files that changed from the base of the PR and between 86ac102 and fb565b7.

📒 Files selected for processing (23)
  • docs-site/src/content/docs/fr/getting-started/quickstart.md
  • docs-site/src/content/docs/fr/guides/providers.md
  • docs-site/src/content/docs/getting-started/quickstart.md
  • docs-site/src/content/docs/guides/providers.md
  • docs-site/src/content/docs/ja/getting-started/quickstart.md
  • docs-site/src/content/docs/ja/guides/providers.md
  • docs-site/src/content/docs/ko/getting-started/quickstart.md
  • docs-site/src/content/docs/ko/guides/providers.md
  • docs-site/src/content/docs/ru/getting-started/quickstart.md
  • docs-site/src/content/docs/ru/guides/providers.md
  • docs-site/src/content/docs/tr/getting-started/quickstart.md
  • docs-site/src/content/docs/tr/guides/providers.md
  • docs-site/src/content/docs/zh-cn/getting-started/quickstart.md
  • docs-site/src/content/docs/zh-cn/guides/providers.md
  • docs-site/src/content/docs/zh-tw/getting-started/quickstart.md
  • docs-site/src/content/docs/zh-tw/guides/providers.md
  • scripts/test-layout/layout.json
  • src/providers/registry/entries-extended.ts
  • structure/ops/docs-and-release.md
  • structure/providers-and-adapters.md
  • tests/fixtures/test-layout-expected.json
  • tests/providers/provider-registry-parity.test.ts
  • tests/providers/tokenlab-provider.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The registry adds TokenLab as an API-key provider with live model discovery. Documentation and preset-count references now describe 100 built-in presets, including 83 key-based presets.

Changes

TokenLab provider

Layer / File(s) Summary
Register and test the TokenLab preset
src/providers/registry/entries-extended.ts:1140–1167, tests/providers/tokenlab-provider.test.ts:1–113, tests/providers/provider-registry-parity.test.ts:47, scripts/test-layout/layout.json:1232, tests/fixtures/test-layout-expected.json:1244
The preset uses the OpenAI Chat adapter and https://api.tokenlab.sh/v1, with gpt-5.6-terra as its seeded default. Discovery requests chat-category models and retains entries marked for chat and tool-use. Tests cover preset configuration, routing, discovery filtering, and key-validation results.
Document TokenLab and update preset counts
docs-site/src/content/docs/guides/providers.md:459, 551–570, docs-site/src/content/docs/*/guides/providers.md, docs-site/src/content/docs/getting-started/quickstart.md, docs-site/src/content/docs/*/getting-started/quickstart.md, structure/providers-and-adapters.md:276–285, structure/ops/docs-and-release.md:89
Provider documentation describes TokenLab’s endpoint, model discovery, key-scoped catalog, and seeded default. Quickstart, provider, and operations documentation updates the total from 99 to 100 and the key-based count from 82 to 83.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant TokenLabRegistry as TokenLab registry preset
  participant TokenLabModels as TokenLab models endpoint
  participant DiscoveryFilter as Registry discovery filter
  participant ProviderRouting as Provider routing
  TokenLabRegistry->>TokenLabModels: Request chat models with bearer authentication
  TokenLabModels-->>DiscoveryFilter: Return model entries
  DiscoveryFilter->>DiscoveryFilter: Keep chat entries with tool-use capability
  DiscoveryFilter-->>ProviderRouting: Provide eligible discovered models
Loading

Merge Risk: ⚪ Minimal · up to fb565

This change adds TokenLab as an ordinary API-key provider preset with filtered model discovery and updates the documented preset counts. No actionable merge-blocking risk was identified in the supplied changes.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to fb565

TokenLab is an optional new destination for API keys and inference requests. Normal discovery applies the intended model filter, but degraded discovery can show a seeded model without confirming that the key can use it. Credential changes outside the reviewed provider-edit path also need verification before key-scoped catalog behavior can be assured.

Retained concerns

  • Medium · security · inferred: TokenLab's key-scoped live catalog uses a generic cache and failure cooldown keyed by provider rather than credential. A credential transition that does not invalidate this state could expose the previous key's model roster or failure state to the next key; the reviewed provider-edit path does invalidate it, but other transitions remain unverified.
  • Low · reliability · observed: When authenticated discovery fails and no stale live roster is available, the catalog can publish the configured default model without confirming that the current key may use it. This weakens the key-scoped catalog guarantee during an outage or rejection, although catalog presence is not evidence of upstream inference authority.
Security review details

Security Blast Radius

  • inferred — Exposure is limited to users who configure and use this optional provider, but their TokenLab key and requests cross into the external service. The reviewed entry does not add OAuth authority, sponsor preference, or a new adapter.

Security Findings and Attack Paths

  • inferred — If a runtime key change bypasses provider-cache invalidation, a subsequent catalog read could inherit the former key's roster or discovery cooldown. No such bypassing transition was established, and no upstream inference authorization bypass was demonstrated.

Trust Boundaries and Controls

  • observed — Matching the fixed registry transport bounds application of TokenLab's discovery URL and filter. Discovery parsing validates model identifiers and applies the filter to original response rows before enrichment; the tests also check Bearer authentication and custom-destination preservation.

Resilience and Maintainability Implications

  • observed — Malformed or failed discovery does not partially publish response rows, but degraded catalog fallback can publish the configured seed. A successful filtered response does not restore that seed merely because it was configured.

Hardening Proposals

  • proposed — Bind TokenLab catalog and discovery-failure cache entries to credential authority, or establish and test invalidation for every credential-change path. Distinguish unverified fallback models from models confirmed by the current key's live response.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (20 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding the TokenLab API-key provider preset. This matches the implementation, tests, and related documentation updates.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (20 skipped: 20 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the enhancement New feature or request label Sep 29, 2026
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (3/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 3/4).
  • The PR is more than 10 commits behind dev; the latest dev box has been unticked.
  • The checklist has been reset: re-test against the latest code and tick the boxes again.

Review readiness checklist

  • ✅ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ⬜ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

3/4 boxes ticked.

The PR is more than 10 commits behind dev; the latest dev box has been unticked.
The checklist has been reset: re-test against the latest code and tick the boxes again.
Automatic draft conversion failed. Please convert this pull request to a draft manually until every box above is ticked.

@lidge-jun

Copy link
Copy Markdown
Owner

리뷰 · 우선순위 56 / 80

이 PR은 TokenLab을 일반 API 키 공급자로 넣습니다. 대시보드의 공급자 추가, CLI 초기 설정, ocx provider add tokenlab에서 같은 프리셋이 보입니다. 어댑터는 이미 있는 openai-chat이고, 주소는 https://api.tokenlab.sh/v1입니다. 스폰서, 순위 가산, OAuth, 새 어댑터는 없습니다.

모델 목록은 GET /v1/models?category=chat로 가져옵니다. 키가 있으면 Bearer로 보냅니다. 목록에서는 tokenlab.category가 chat이고 tool-use가 있는 줄만 남깁니다. 그림·영상·임베딩·결정 모델은 빠집니다. 시드 기본 모델은 gpt-5.6-terra입니다. 키가 그 모델을 못 쓰면, 살아 있는 목록이 시드를 덮어써서 그 이름이 다시 붙지 않습니다. 예전에 같은 이름으로 만든 사용자 지정 목적지는 preserveCustomDestination으로 그대로 둡니다.

가이드와 structure/providers-and-adapters.md에 설정·발견 범위·약관 링크를 적었습니다. 프리셋 개수 문구는 100개(키 기반 83)로 맞췄습니다. 테스트는 진입점, 라우팅, 혼합 목록 필터, 키별 목록 우선, 키 거절/장애 구분을 픽스처로 잠급니다. 베이스는 dev입니다. types.ts/config.ts 나누기는 없고, 같은 주제의 다른 열린 PR도 없습니다.

작성자가 공개 API로 확인한 값은 이 리뷰에서도 맞습니다. gpt-5.6-terra의 max_input_tokens 1050000, max_output_tokens 128000은 레지스트리 숫자와 같습니다. 공개 chat 목록 142개 중 tool-use chat은 112개입니다. 잘못된 키는 401입니다.

라인 - PR 본문 · 승인 증거. 작성자는 TOKENLAB AI INC. 운영자이고, 재판매·라우팅 허가 서류를 이 PR에 붙이지 않았다고 스스로 적었습니다. 공개 문서와 회사 이름만으로는 그 허가를 증명하지 않는다고도 적었습니다. 코드 버그가 아니라, 게이트웨이 프리셋을 받을지 막는 입장 게이트입니다. 지금 상태는 draft이고, 리뷰 준비 체크는 4칸 중 2칸만 채워져 있습니다.

라인 - 라이브 추론. 본문은 실제 키로 스트리밍·도구 호출 실행을 안 했다고 적습니다. 로컬 테스트는 발견·검증 픽스처입니다. 목록 필터와 키 401은 공개 응답과 맞지만, 에이전트 턴이 끝까지 가는지는 이 헤드만으로는 증명되지 않습니다.

라인 - tests/providers/tokenlab-provider.test.ts · 사용자 지정 baseUrl. 주소를 바꾸면 발견 URL에서 category=chat이 빠지고, 레지스트리 발견 스펙도 꺼집니다. 같은 이름 맞춤 목적지를 지키려는 기존 패턴과 같습니다. TokenLab이 아닌 게이트로 돌리면 chat/tool-use 필터는 더 이상 적용되지 않습니다.

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

운영자가 직접 올린 게이트웨이 프리셋입니다. 재판매·라우팅 허가 서류를 받기 전에는 draft로 둘지, 공개 계약과 약관만으로 받을지 정해 주세요. 라이브 도구 호출 확인을 머지 전에 필수으로 둘지도 정해 주세요. 베이스 dev는 맞습니다.

너의 추천

레지스트리·문서·테스트 모양은 Opper 같은 키 게이트웨이 프리셋과 같고, 발견 필터도 공개 목록과 맞습니다. 닫을 중복·무효 PR은 없습니다. 허가 서류와 (가능하면) 실제 키 한 번의 도구 호출 확인이 오기 전에는 머지하지 마세요. 그 두 가지가 오면 draft를 풀고 체크리스트를 채운 뒤 dev에 넣으면 됩니다.

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

@hedging8563

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I have now completed the real-key streaming/tool-call verification on the unchanged PR head 863ffe755740bc0f17367d6580bba919a0e10c28 (2026-09-29, 05:45 UTC) and updated the PR description.

The harness used the actual TokenLab registry seed and routeModel, then the production createOpenAIChatAdapter().buildRequest/parseStream implementation against https://api.tokenlab.sh/v1/chat/completions, with a real test API key and the preset default model gpt-5.6-terra.

Check Live result
Authenticated model discovery HTTP 200; 142 chat rows, 112 passed the registry's chat/tool-use filter; default model present
First streamed turn Emitted add with a=19, b=23; finish reason tool_calls
Tool-result continuation Harness calculated 42 locally and replayed the result under the original tool-call ID; second streamed turn answered exactly 42, with finish reason stop
Stream completion Both responses: HTTP 200, text/event-stream, [DONE], and one successful adapter terminal event; no adapter errors or incomplete events
Bounded execution Two inference requests, at most 1,024 output tokens each, no retries; reported usage: 350 input / 26 output tokens total

This verifies one real model/key through the production adapter and client-side tool loop. It is not a claim of full Codex UI/proxy coverage or of a live restricted-key catalog matrix; those boundaries are retained in the description. No credentials or internal routing details are included.

For the separate provider-admission question, could a maintainer clarify which evidence forms you accept: applicable upstream public terms, a redacted supply/reseller agreement, or an authorization email? If non-public supporting documents are needed, is there a private review channel, and which minimum facts must remain visible after redaction? We have not attached authorization documents, and this technical verification is not presented as proof of resale/routing rights. The PR remains a draft pending the admission decision.

The English provider guide already states 100 presets (83 key-based) after the
TokenLab entry, but the translated guides, every quickstart and the structure ops
record still said 99 (82). tests/ci-workflows/docs-provider-preset-counts.test.ts,
which landed on dev after this branch was cut, derives both numbers from the
registry and failed in 16 places on the merge with dev.
@lidge-jun
lidge-jun marked this pull request as ready for review September 29, 2026 12:40
@lidge-jun
lidge-jun self-requested a review as a code owner September 29, 2026 12:40
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration into dev

Merging on the repository owner's explicit instruction, under the dev maintainer-integration policy in MAINTAINERS.md. This is an integration decision, not an independent approving review.

Admission decision. The open item in the description was routing/resale authorization. The owner has decided to admit TokenLab as a canonical preset without a separate reseller document. The record behind that decision:

  • The operator (TOKENLAB AI INC.) states that its Official delivery mode uses TokenLab's own enterprise accounts on official API channels, generally without separate signed reseller agreements, and that its Verified mode also includes official API relays and reverse-engineered access. Choosing a delivery mode is the operator's and the user's responsibility; opencodex does not audit or guarantee upstream sourcing.
  • The preset makes no claim of upstream endorsement, changes no routing default, and sends the user's own key only to https://api.tokenlab.sh/v1 (credential-destination review: one new key destination, openai-chat adapter, discovery at /v1/models?category=chat, no OAuth).
  • The live streaming/tool-call check the earlier review asked for is in the author's comment above.

TokenLab has since become a Standard sponsor. Sponsor placement lands in a separate maintainer PR; this PR stays an ordinary preset, as described.

Fix pushed to this branch. After the branch was updated onto dev, tests/ci-workflows/docs-provider-preset-counts.test.ts (which landed on dev after this branch was cut) failed in 16 places. The translated guides, every quickstart, and the structure ops record still said 99 presets (82 key-based). fb565b7c48 recounts those anchored lines to 100 (83).

Exact-head verification. Head fb565b7c48eb215d7806e7e1202a4d84ded2bf4d — 24 checks passed, 7 skipped, 0 failed or pending, including Cross-platform CI run 36567400620 (four test shards, gates, docs site build, desktop shell, npm-global Ubuntu/Windows, docker smoke) and React Doctor. The Windows and macOS matrix jobs are skipped by their path conditions for this diff; they are not missing.

@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner September 29, 2026 12:40
@github-actions
github-actions Bot marked this pull request as draft September 29, 2026 12:40
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer note: I ticked the last two readiness boxes as the integrating maintainer. CodeRabbit's assertive review at fb565b7c48 generated no actionable comments, and the PR has no open review threads or change requests. The earlier maintainer review asked for a live tool call (done by the author above) and an admission decision (recorded in the integration comment).

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants