Universal AI Command-Line Interface — Interact with multiple AI providers using a single, elegant CLI tool.
anyai-cli is an open-source CLI tool that provides a unified interface to interact with multiple AI providers (OpenAI, Anthropic, Mistral, Google Gemini, Alibaba Qwen) using your own API keys. No vendor lock-in, no account creation needed — just your API credentials.
✨ Multi-Provider Support — Switch between OpenAI, Anthropic, Mistral, Gemini, and Qwen
🔐 Secure API Key Storage — Uses keytar for secure credential management
⚡ One-Shot Queries — anyai ask "Your question"
💬 Interactive Chat — Real-time conversational AI
🎨 Modern CLI UX — Styled banners, spinners, and colored output
🔧 Easy Configuration — Interactive setup wizard
🚀 Fast & Lightweight — Minimal dependencies, instant responses
npm install -g anyai-cliThen use anyai from anywhere:
anyai ask "What is Node.js?"npm install anyai-cli
npx anyai ask "Your question"anyai initThis creates a configuration directory at ~/.anyai/.
anyai configureThe interactive wizard will:
- Ask you to select an AI provider
- Securely store your API key
- Save your configuration
One-shot query:
anyai ask "Explain quantum computing in simple terms"Interactive chat:
anyai chatDisplays the banner and help information.
$ anyai
┌─────────────────────────────────────────────────────────────┐
│ │
│ ___ ___ _ _ _____ _ │
│ / _ \ / _ \ / \ / | |_ _| / \ │
│ | |_| || | | | / _ \ | | | | / _ \ │
│ | _ || |_| |/ ___ \ | | | | / ___ \ │
│ |_| |_| \___//_/ \_\|_| |_|/_/ \_\ │
│ │
│ Universal AI CLI — Interact with any AI provider │
│ v0.1.0 │
│ │
└─────────────────────────────────────────────────────────────┘
Get started:
1. Initialize your config:
anyai init
2. Configure your API key:
anyai configure
3. Try an AI provider:
anyai ask "What is Node.js?"
Initialize the configuration directory and files.
$ anyai init
📦 Initializing anyai-cli
─────────────────────────────────────────────────────────────
✓ Configuration directory created at: /home/user/.anyai
ℹ Next: Run "anyai configure" to set up your API keyInteractive setup wizard to configure an AI provider.
$ anyai configure
🔧 Configuring anyai-cli
─────────────────────────────────────────────────────────────
? Select an AI provider:
❯ openai
anthropic
mistral
gemini
qwen
? Enter your API key: ••••••••••••••••••••••••••
✓ API key stored securely for openai
✓ Configuration savedDisplay your current configuration.
$ anyai config
┌─────────────────────────────────────────────────────────────┐
│ Current Configuration: │
│ │
│ Provider: openai │
│ Model: gpt-4o │
│ Provider Models: {"openai":"gpt-4o","gemini":"gemini-1.5-pro","mistral":"mistral-large-latest"}
│ Config File: /home/user/.anyai/config.json │
└─────────────────────────────────────────────────────────────┘Select or change the active model for your configured provider.
$ anyai model
? Select model for openai:
❯ gpt-4o
gpt-4-turbo
gpt-4
gpt-3.5-turbo
✓ Model changed to: gpt-4oSend a one-shot query to the AI.
$ anyai ask "What is the capital of France?"
⠙ Querying openai...
✓ Response received
─────────────────────────────────────────────────────────────
The capital of France is Paris, the most populous city in the
country and the center of French culture, politics, and economy.
─────────────────────────────────────────────────────────────Start an interactive chat session.
$ anyai chat
💬 Interactive Chat Mode
─────────────────────────────────────────────────────────────
ℹ Provider: openai | Model: gpt-4o
ℹ Type "exit" or "quit" to end the conversation
? You: What is quantum entanglement?
⠹ Thinking...
✓
AI: Quantum entanglement is a phenomenon in quantum mechanics
where two or more particles become correlated in such a way that...
? You: Can you explain it more simply?
⠹ Thinking...
✓
AI: Sure! Imagine two magic coins...Configuration is stored in ~/.anyai/config.json:
{
"provider": "openai",
"model": "gpt-4o",
"providerModels": {
"openai": "gpt-4o",
"gemini": "gemini-1.5-pro",
"mistral": "mistral-large-latest"
}
}You can edit this file directly:
cat ~/.anyai/config.jsonModels:
gpt-4o(recommended)gpt-4-turbogpt-4gpt-3.5-turbo
Setup:
- Get your API key from platform.openai.com
- Run
anyai configureand selectopenai
Models:
claude-3-5-sonnet-20241022(recommended)claude-3-5-haiku-20241022claude-3-opus-20250219
Setup:
- Get your API key from console.anthropic.com
- Run
anyai configureand selectanthropic
Models:
mistral-large-latest(recommended)mistral-medium-latestmistral-small-latest
Setup:
- Get your API key from console.mistral.ai
- Run
anyai configureand selectmistral
Models:
gemini-2.0-flash(recommended)gemini-1.5-progemini-1.5-flash
Setup:
- Get your API key from aistudio.google.com
- Run
anyai configureand selectgemini
Models:
qwen-max(recommended)qwen-plusqwen-turbo
Setup:
- Get your API key from dashscope.aliyuncs.com
- Run
anyai configureand selectqwen
anyai-cli looks for API keys in this order:
-
Environment Variable (highest priority)
export ANYAI_OPENAI_API_KEY="sk-..." export ANYAI_ANTHROPIC_API_KEY="sk-ant-..." export ANYAI_MISTRAL_API_KEY="..." export ANYAI_GEMINI_API_KEY="..." export ANYAI_QWEN_API_KEY="..."
-
Secure Keystore (fallback)
- Uses
keytarfor secure credential storage - Credentials stored in system keychain
- Uses
✅ DO:
- Use environment variables for CI/CD
- Use keystore for local development
- Rotate API keys regularly
- Never commit API keys to version control
❌ DON'T:
- Store API keys in plain text files
- Share your API keys with others
- Commit
.envfiles to git
# OpenAI
export ANYAI_OPENAI_API_KEY="sk-..."
# Anthropic
export ANYAI_ANTHROPIC_API_KEY="sk-ant-..."
# Mistral
export ANYAI_MISTRAL_API_KEY="..."
# Google Gemini
export ANYAI_GEMINI_API_KEY="..."
# Alibaba Qwen
export ANYAI_QWEN_API_KEY="..."Enable debug logging:
export DEBUG=1
anyai ask "Your question"$ anyai ask "Explain this code: const x = [1,2,3].map(n => n * 2)"$ anyai ask "Translate this to Spanish: Hello, how are you?"$ anyai chat
? You: What's the weather?
AI: I don't have access to real-time weather data...
? You: Can you recommend a travel destination?
AI: Based on your interests...
? You: exit
Goodbye!# Currently using OpenAI
$ anyai config
# Switch to Mistral
$ anyai configure
? Select an AI provider: mistral
? Enter your API key: ...
# Now using Mistral
$ anyai ask "Hello!"anyai-cli/
├── bin/
│ └── anyai.js # CLI entry point
├── src/
│ ├── commands/
│ │ ├── ask.js # One-shot query command
│ │ ├── chat.js # Interactive chat command
│ │ ├── config.js # Display config command
│ │ ├── configure.js # Setup wizard command
│ │ ├── init.js # Initialize command
│ │ └── model.js # Model selection command
│ ├── providers/
│ │ ├── base.js # Abstract provider class
│ │ ├── openai.js # OpenAI implementation
│ │ ├── anthropic.js # Anthropic implementation
│ │ ├── mistral.js # Mistral implementation
│ │ ├── gemini.js # Google Gemini implementation
│ │ ├── qwen.js # Alibaba Qwen implementation
│ │ └── index.js # Provider factory
│ ├── config/
│ │ ├── manager.js # Config file management
│ │ ├── keystore.js # Keytar wrapper
│ │ └── apikeys.js # API key management
│ ├── ui/
│ │ ├── banner.js # Banner rendering
│ │ ├── colors.js # Color definitions
│ │ ├── logger.js # Logging utilities
│ │ └── spinner.js # Loading spinner
│ └── utils/
│ └── helpers.js # Utility functions
├── package.json
└── README.md
git clone https://github.com/yourusername/anyai-cli.git
cd anyai-clinpm installnpm run dev -- ask "Test question"
npm run dev -- configure
npm run dev -- chat- Create a new file in
src/providers/(e.g.,newprovider.js) - Extend the
Providerbase class - Implement required methods:
generate(),validate(),getModels(),getDefaultModel() - Register in
src/providers/index.js
Example:
// src/providers/newprovider.js
const Provider = require('./base');
class NewProviderClass extends Provider {
constructor() {
super('newprovider');
}
getDefaultModel() {
return 'default-model';
}
getModels() {
return ['model-1', 'model-2'];
}
async validate() {
// Validate API key
}
async generate(prompt, options) {
// Generate response
}
}
module.exports = NewProviderClass;Then in src/providers/index.js:
const NewProviderClass = require('./newprovider');
const PROVIDERS = {
// ... existing providers
newprovider: NewProviderClass,
};$ anyai ask "test"
✗ No provider configured. Run "anyai configure" first.Solution: Run anyai configure to set up your first provider.
✗ Invalid OpenAI API keySolution: Check your API key and run anyai configure again.
✗ OpenAI API error: Request failedSolution:
- Check your internet connection
- Verify your API key is valid
- Check provider API status
- Try a different provider
# Make sure to export, not just set
export ANYAI_OPENAI_API_KEY="sk-..."
# Verify it's set
echo $ANYAI_OPENAI_API_KEYWe welcome contributions! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License — see the LICENSE file for details.
- Built with Commander.js for CLI framework
- UI styling with Chalk and Boxen
- Loading spinners with Ora
- Secure key storage with Keytar
- Interactive prompts with Inquirer.js
For issues, feature requests, or questions:
- 📧 Email: support@example.com
- 🐛 GitHub Issues: Report a bug
- 💬 Discussions: Start a discussion
anyai-cli is a third-party tool and is not affiliated with OpenAI, Anthropic, Mistral, Google, or Alibaba. Each provider has its own terms of service and pricing. Please review their documentation and pricing before using.
Made with ❤️ for the AI developer community