rk-ai-cli-chat
v1.0.1
Published
A minimal command-line chatbot powered by Claude (Anthropic) with streaming responses and persistent conversation history.
Readme
AI CLI Chat
A minimal command-line chatbot powered by Claude (Anthropic) with streaming responses and persistent conversation history.
Features
- Real-time streaming output — responses print token-by-token as they arrive
- Multi-turn conversation — full message history is maintained within a session
- Automatic retry — backs off and retries up to 3 times on API overload errors
- Simple loop — type a message, get a response, repeat until you type
exit
Requirements
- Node.js 18+
- An Anthropic API key
Setup
npm install
export ANTHROPIC_API_KEY=your_api_key_hereUsage
node chat.mjs🚀 AI Chat CLI — type "exit" to quit
You: Hello!
🤖 Claude: Hi! How can I help you today?
You: exit
Goodbye!Type exit to end the session.
How it works
- Each user message is appended to a
historyarray and sent toclaude-sonnet-4-20250514via the Anthropic SDK's streaming API. - The assistant's full response is captured and appended to history, so the model has context for every follow-up message.
- On
overloaded_errorresponses, the script waits 2 s, 4 s, then 6 s between retries before giving up.
