Skip to content

Use official Command Code Provider API#6

Draft
patlux wants to merge 5 commits into
mainfrom
issue-5-provider-api
Draft

Use official Command Code Provider API#6
patlux wants to merge 5 commits into
mainfrom
issue-5-provider-api

Conversation

@patlux

@patlux patlux commented May 26, 2026

Copy link
Copy Markdown
Owner

Why

Refs #5. Command Code asked integrations to stop using internal/reverse-engineered API paths and use the documented Provider API instead. This moves the provider to the official API surface and keeps both authentication paths available.

What

  • Replaced the custom /alpha/generate streaming implementation with pi's built-in OpenAI-compatible and Anthropic provider support.
  • Uses the documented Command Code Provider API:
    • GET /provider/v1/models for model discovery
    • POST /provider/v1/chat/completions for non-Claude models
    • POST /provider/v1/messages for Claude models
  • Keeps the existing browser-assisted /login flow.
  • Adds a second /login path where users can paste a Command Code Studio API key directly.
  • Preserves existing non-interactive auth options: COMMANDCODE_API_KEY, ~/.commandcode/auth.json, and pi auth storage.
  • Removes the internal custom stream serializer/parser and related tests.

How

  • Fetch models dynamically from the official /models endpoint at startup.
  • Classify claude-* models as anthropic-messages; all other models use openai-completions.
  • Use COMMANDCODE_API_BASE for the Provider API base and COMMANDCODE_MODELS_URL for model-list mocks/tests.
  • Route Claude model base URLs through the Anthropic SDK-compatible base by stripping the trailing /v1.
  • Store pasted API keys using the same OAuth-shaped pi credentials as the existing login flow.

Testing

Local checks pass:

  • npm run typecheck
  • npm run format:check
  • npm test
  • npm pack --dry-run
  • pi --no-extensions -e ./index.ts --list-models

Live Provider API completion calls are untested because I do not have the required Command Code Pro plan. I also do not use Command Code anymore because chatgpt-5.5 >>> any-other-model ;).

If someone with a Command Code Pro plan can test this against the live Provider API, please let us know whether both /chat/completions and /messages work as expected.

@patlux patlux marked this pull request as draft May 26, 2026 20:45
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@bl4zee1g

Copy link
Copy Markdown

this will make it impossible to use with go plan right?

@patlux

patlux commented May 30, 2026

Copy link
Copy Markdown
Owner Author

this will make it impossible to use with go plan right?

No. This implements the use of the official API which only works with the Pro Plan.

The current authentication works with the Go plan.

@fbraza

fbraza commented Jun 8, 2026

Copy link
Copy Markdown

@patlux Hello :-) Are you still planning implementing this ? Many thanks

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.

3 participants