⚠️ Note: Not all examples are tested yet. Please use with caution and report any issues.
Complete JavaScript examples for the Rahyana AI API with Node.js. Build powerful AI applications with modern JavaScript and async/await patterns.
- Node.js 20+ and npm 10+
- A Rahyana API key (get one at rahyana.ir)
# Install dependencies
npm install
# Set your API key
export API_KEY_OVERRIDE="your_api_key_here"# Run basic chat
npm run examples:basic
# Run streaming chat
npm run examples:streaming
# Run all examples
npm run examples:allbasic-chat.js- Simple chat completionsstreaming-chat.js- Real-time streaming responsesimage-analysis.js- Multimodal image analysisaudio-processing.js- Audio processing and transcriptionpdf-processing.js- PDF document analysisweb-search.js- Web search integrationtool-calling.js- Function calling examplesjson-mode.js- Structured JSON responses
legacy-completions.js- Text completion endpoint
get-models.js- List available AI models
ai-chatbot.js- Complete chatbot implementationai-code-assistant.js- Code generation and reviewai-content-generator.js- Content generation system
ai-voice-assistant.js- Voice assistant with text fallbackai-data-analyzer.js- Data analysis toolai-automation-suite.js- Automation workflowsai-web3-integration.js- Web3 and blockchain integration
ai-testing/ai-test-generator.js- Intelligent test generationai-monitoring/ai-performance-monitor.js- Performance monitoringai-docs/ai-documentation-generator.js- Documentation generationai-review/ai-code-reviewer.js- Code review assistantai-devops/ai-cicd-assistant.js- CI/CD automation
- ✅ Modern ES modules
- ✅ Async/await patterns
- ✅ Comprehensive error handling
- ✅ Streaming support
- ✅ TypeScript-ready structure
- ✅ Production-ready code
import { basicChat } from './chat-completions/basic-chat.js';
const response = await basicChat({
apiKey: process.env.API_KEY_OVERRIDE,
message: 'Hello, Rahyana!'
});
console.log(response);import { streamingChat } from './chat-completions/streaming-chat.js';
for await (const chunk of streamingChat({
apiKey: process.env.API_KEY_OVERRIDE,
message: 'Tell me a story'
})) {
process.stdout.write(chunk);
}# Run tests
npm test
# Run with coverage
npm run test:coverage
# Watch mode
npm run test:watchMIT License - see LICENSE for details.