Examples
Explore these examples to learn how to use Meloqui's features. The source code for all examples is available in the examples directory.
Basic Usage
| Example | Description | Command |
|---|---|---|
| Basic Chat | Simple chat interaction. | npx ts-node examples/basic-chat.ts |
| Streaming | Real-time response streaming. | npx ts-node examples/streaming.ts |
| History | Multi-turn conversations. | npx ts-node examples/with-history.ts |
| Storage | Persistent file storage. | npx ts-node examples/with-storage.ts |
Providers
| Example | Description | Command |
|---|---|---|
| Anthropic | Chat with Claude models. | npx ts-node examples/anthropic-chat.ts |
| Chat with Gemini models. | npx ts-node examples/google-chat.ts | |
| Ollama | Chat with local models. | npx ts-node examples/ollama-chat.ts |
Enterprise Features
| Example | Description | Command |
|---|---|---|
| Retry | Automatic retries with backoff. | npx ts-node examples/with-retry.ts |
| Rate Limiting | Client-side rate limiting. | npx ts-node examples/with-rate-limiting.ts |
| Logging | Structured logging. | npx ts-node examples/with-logging.ts |
Advanced
| Example | Description | Command |
|---|---|---|
| Tools / Agents | Function calling and agents. | npx ts-node examples/with-tools.ts |
| Vision | Multimodal image analysis. | npx ts-node examples/with-vision.ts |
| RAG | Retrieval Augmented Generation. | npx ts-node examples/with-rag.ts |
Recipes
Complete mini-applications combining multiple features:
| Recipe | Description | Command |
|---|---|---|
| Codestral Assistant | Coding assistant with file context using Mistral. | npx ts-node examples/recipes/codestral-assistant |
| CLI Chatbot | Interactive terminal chat with persistence. | npx ts-node examples/recipes/cli-chatbot |
| Document Q&A | Ask questions about local documents using RAG. | npx ts-node examples/recipes/doc-qa |
| API Endpoint | REST API with SSE streaming. | npx ts-node examples/recipes/api-endpoint.ts |
| Code Review Bot | AI code reviewer with vision support. | npx ts-node examples/recipes/code-review-bot |
| Multi-Provider Fallback | Automatic failover between providers. | npx ts-node examples/recipes/multi-provider-fallback |
| Structured Data Extractor | Extract JSON from unstructured text. | npx ts-node examples/recipes/structured-extractor |
| Agentic Assistant | Multi-step task execution with tools. | npx ts-node examples/recipes/agentic-assistant |
| Image Analyzer | Batch image analysis with vision AI. | npx ts-node examples/recipes/image-analyzer |
Running Examples
Install dependencies
bashnpm installSet API Keys
bashexport OPENAI_API_KEY=your_key export ANTHROPIC_API_KEY=your_key export GOOGLE_API_KEY=your_keyRun an example
bashnpx ts-node examples/basic-chat.ts
