Skip to content

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

ExampleDescriptionCommand
Basic ChatSimple chat interaction.npx ts-node examples/basic-chat.ts
StreamingReal-time response streaming.npx ts-node examples/streaming.ts
HistoryMulti-turn conversations.npx ts-node examples/with-history.ts
StoragePersistent file storage.npx ts-node examples/with-storage.ts

Providers

ExampleDescriptionCommand
AnthropicChat with Claude models.npx ts-node examples/anthropic-chat.ts
GoogleChat with Gemini models.npx ts-node examples/google-chat.ts
OllamaChat with local models.npx ts-node examples/ollama-chat.ts

Enterprise Features

ExampleDescriptionCommand
RetryAutomatic retries with backoff.npx ts-node examples/with-retry.ts
Rate LimitingClient-side rate limiting.npx ts-node examples/with-rate-limiting.ts
LoggingStructured logging.npx ts-node examples/with-logging.ts

Advanced

ExampleDescriptionCommand
Tools / AgentsFunction calling and agents.npx ts-node examples/with-tools.ts
VisionMultimodal image analysis.npx ts-node examples/with-vision.ts
RAGRetrieval Augmented Generation.npx ts-node examples/with-rag.ts

Recipes

Complete mini-applications combining multiple features:

RecipeDescriptionCommand
Codestral AssistantCoding assistant with file context using Mistral.npx ts-node examples/recipes/codestral-assistant
CLI ChatbotInteractive terminal chat with persistence.npx ts-node examples/recipes/cli-chatbot
Document Q&AAsk questions about local documents using RAG.npx ts-node examples/recipes/doc-qa
API EndpointREST API with SSE streaming.npx ts-node examples/recipes/api-endpoint.ts
Code Review BotAI code reviewer with vision support.npx ts-node examples/recipes/code-review-bot
Multi-Provider FallbackAutomatic failover between providers.npx ts-node examples/recipes/multi-provider-fallback
Structured Data ExtractorExtract JSON from unstructured text.npx ts-node examples/recipes/structured-extractor
Agentic AssistantMulti-step task execution with tools.npx ts-node examples/recipes/agentic-assistant
Image AnalyzerBatch image analysis with vision AI.npx ts-node examples/recipes/image-analyzer

Running Examples

  1. Install dependencies

    bash
    npm install
  2. Set API Keys

    bash
    export OPENAI_API_KEY=your_key
    export ANTHROPIC_API_KEY=your_key
    export GOOGLE_API_KEY=your_key
  3. Run an example

    bash
    npx ts-node examples/basic-chat.ts

Released under the MIT License.