Basic Usage

A typical usage example is shown below:

       PuppyChatter<PromptParameters, Response> chatter=new OpenrouterPuppyChatter("open router key");
       String session=chatter.createSession();
       Response response=chatter.bark(session, "Hello", new PromptParameters("user"));
       System.out.println(response.getMessage());
       chatter.closeSession(session);

In the example above, the openrouter implementation of PuppyChatter is used. Users have to obtain a key from open router ( https://openrouter.ai ) and fill the key into the parameter of the OpenrouterPuppyChatter. The bark method is used for sending messages to the connected AI service. Before invoking bark, a session has to be created via the createSession method. Note that within the same session, a conversation history is kept, so multi-turn conversations are possible.

Sometimes, users may want to choose a specific AI model manually. In such a case, add model:modelName before the sending message. For example:

       PuppyChatter<PromptParameters, Response> chatter=new OpenrouterPuppyChatter("open router key");
       String session=chatter.createSession();
       Response response=chatter.bark(session, "model: model:google/gemma-2-9b-it:free Hello", new PromptParameters("user"));
       System.out.println(response.getMessage());
       chatter.closeSession(session);

In the example above, the google/gemma-2-9b-it:free model is enforced.