Skip to content

feat(providers): add Command Code, OpenCode Go and DeepSeek with per-provider key storage - #199

Open
sazenlabs wants to merge 2 commits into
Musheer360:masterfrom
sazenlabs:feat/providers-api
Open

sazenlabs wants to merge 2 commits into
Musheer360:masterfrom
sazenlabs:feat/providers-api

Conversation

@sazenlabs

Copy link
Copy Markdown

What

Adds three OpenAI-compatible providers to the existing transport:

Provider Endpoint Default model
Command Code https://api.commandcode.ai/provider/v1 deepseek/deepseek-v4-flash
OpenCode Go https://opencode.ai/inference/go/openai/v1 glm-5.3-flash
DeepSeek https://api.deepseek.com deepseek-flash

Why key validation is provider-specific

  • Command Code and OpenCode Go serve /models without auth, so the shared GET validator accepted any string (a placeholder key reported "Valid key added!"). They validate with a single authenticated 1-token probe instead. That also surfaces Command Code's 403 upgrade_required (the Go plan has no API access) as its own message instead of "invalid key".
  • DeepSeek's /models does require auth, so it keeps the free GET path.
  • The probe's status table is a pure function (ApiClientUtils.probeAcceptsKey) covered by a table test: 2xx and auth-passed 4xx pass, 401/403 fail, 404 passes only when the body indicates the model was unavailable (a valid key must not be rejected because the fixed probe model is not provisioned), 405/5xx fail.

Catalog correctness

Command Code's catalog lists every model and marks routes in supported_endpoints; its Claude models answer /messages only and return 400 on /chat/completions. parseChatCompletionModelIds filters on that metadata and treats it as authoritative once present, so the picker cannot regress to offering models that can never work. Catalogs without the field still fall back to the plain parser.

Per-provider key storage

Keys move from one shared pool to keys_array_<provider>. The shared pool meant switching providers sent the previous vendor's keys to the new endpoint, where they 401'd and were benched; switching back could then find nothing. The pre-provider pool is migrated once to the provider active at first read — and only for the three providers that existed while it was in use.

upgrade_required is account-level, so it no longer rotates through every key, and extractApiErrorCode falls back to error.type / root code for gateways that report the reason there.

Tests

./gradlew testDebugUnitTest — 209 tests passing, including new coverage for provider routing/defaults, catalogs, per-provider scoping and cache invalidation, legacy migration, parser filtering and the probe status table. Also exercised on a physical device against the live endpoints.

This is the first of two PRs; the Settings UI change follows in a stacked PR that builds on this one.

sazenlabs and others added 2 commits November 6, 2026 10:47
Three OpenAI-compatible providers, wired through the existing transport:

- Command Code (https://api.commandcode.ai/provider/v1) and OpenCode Go
  (https://opencode.ai/inference/go/openai/v1) serve their model catalog
  without auth, so keys are validated with a single authenticated 1-token
  probe instead of the shared GET /models path. That also surfaces
  upgrade_required (Command Code's Go plan has no API access) as its own
  message instead of "invalid key".
- DeepSeek (https://api.deepseek.com) validates through GET /models, which
  does require auth.
- Command Code's catalog marks Claude models as /messages-only. The picker
  filters on supported_endpoints so it never offers a model that would 400
  on /chat/completions.

Key storage is now per provider (keys_array_<provider>) instead of one shared
pool: switching providers used to send the previous vendor's keys to the new
endpoint, where they 401'd and were benched. The pre-provider pool migrates
once to the active provider, and only for the three providers that existed
while it was in use.

upgrade_required no longer burns the rotation (it is account-level), and
extractApiErrorCode now falls back to error.type / root code so gateways that
report the reason there are still classified correctly.

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
Resources the new provider layer needs: display names for Command Code,
OpenCode Go and DeepSeek, and the message used when a provider answers
403 upgrade_required (the account's plan has no API access).

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant