Skip to content

feat(cli): prompt for OpenAI API key in interactive mode - #403

Merged
rabisg merged 4 commits into
thesysdev:mainfrom
AliaksandrNazaruk:feat/interactive-api-key
Apr 3, 2026
Merged

feat(cli): prompt for OpenAI API key in interactive mode#403
rabisg merged 4 commits into
thesysdev:mainfrom
AliaksandrNazaruk:feat/interactive-api-key

Conversation

@AliaksandrNazaruk

Copy link
Copy Markdown
Contributor

Summary

When running create-chat-app interactively, prompt the user for their OpenAI API key instead of printing manual instructions. If a key is provided, the CLI creates the .env file automatically and simplifies the getting-started output. In non-interactive mode, behavior is unchanged.

Changes

  • packages/openui-cli/src/commands/create-chat-app.ts: After installing dependencies, prompt for the OpenAI API key using the existing resolveArgs helper. If provided, write .env and show a streamlined message. If skipped (blank input) or non-interactive, show the original instructions.

Closes #399

When running create-chat-app interactively, prompt the user for their
OpenAI API key, create the .env file automatically, and simplify the
getting-started instructions. In non-interactive mode, the behavior
remains unchanged.

Closes #399

@rabisg rabisg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This works great - just a minor change for simplifying the code


console.info(getStartedMessage(name, devCmd));
if (!options.noInteractive) {
const apiKeyArgs = await resolveArgs(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

resolveOne was meant as a utility for when the value can be passed from both the cli as flags and in interactive mode. Since we don't want this in non-interactive mode or a flag for this, you can directly use inquirer here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1

Also, this can be reorganized into a fn in the lib/ folder to clean up the command and keep it as a high-level orchestrator.

@AbhinRustagi AbhinRustagi Mar 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's also a merge conflict to be resolved with the skill option.

I think it can be extended to a 3-step scenario

  • Ask for OpenAI SDK BaseUrl (read a comment/issue about someone using OpenRouter, I personally used Gemini) (default value can be something like "Use OpenAI")
  • (If they add a custom url) Ask for model name
  • Ask for Api Key

Wdyt?

Drawbacks: prolongs the setup process

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can keep this PR simple and just take the API key
We can discuss the long term roadmap for OpenUI cli setup on the issue

@rabisg rabisg self-assigned this Mar 26, 2026
@rabisg

rabisg commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

hi @AliaksandrNazaruk - would love to get this merged. Are you planning on patching the PR anytime soon?

@rabisg
rabisg enabled auto-merge (squash) April 3, 2026 09:16
@rabisg
rabisg merged commit 9495c5c into thesysdev:main Apr 3, 2026
1 check passed
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.

Ask for OpenAI key in interactive mode

4 participants