Lesson 3: Model Selection

This lesson demonstrates how easy it is to switch between different models and observe the impact it has on the output, even with the exact same prompt.

Code: lesson_3_model_selection.mjs

The key here is the array of model names. The script iterates through this list, passing each model name to the client.chat.session() method to create a new session for each experiment.

// lesson_3_model_selection.mjs
// Merci SDK Tutorial: Lesson 3 - Model Selection

// --- IMPORTS ---
import { MerciClient, createUserMessage } from '../lib/merci.2.14.0.mjs';
import { token } from '../secret/token.mjs';

const MODELS_TO_TEST = [
    'google-chat-gemini-flash-2.5',
    'openai-gpt-5-mini',
    'anthropic-claude-3.5-haiku'
];

async function runModelExperiment(client, modelName, prompt) {
    console.log(`\n--- Experiment: Running prompt with ${modelName} ---`);
    const chatSession = client.chat.session(modelName);
    const messages = [ createUserMessage(prompt) ];
    // ... stream processing logic ...
}

async function main() {
    const client = new MerciClient({ token });
    const userPrompt = "Explain the concept of 'deja vu' in a single, creative sentence.";

    for (const model of MODELS_TO_TEST) {
        await runModelExperiment(client, model, userPrompt);
    }
}

main().catch(console.error);

Expected Output

The script will run the same prompt against each model and print the results. Notice the differences in tone, style, and vocabulary between the models.

--- FINAL COMPARISON ---
👤 User Prompt > Explain the concept of 'deja vu' in a single, creative sentence.
--------------------------
🤖 google-chat-gemini-flash-2.5:
   Déjà vu is the universe's way of letting you feel a ripple from a parallel life.

🤖 openai-gpt-5-mini:
   It's the strange sensation that your life's script just had a typo corrected in real-time.

🤖 anthropic-claude-3.5-haiku:
   Déjà vu is the brief, startling echo of a memory you haven't made yet.
--------------------------