Why use the generate and store mode?

The generate and store mode is an all-integrated approach that combines the functionality of both the generate mode and the store mode. This mode is ideal for scenarios where you want to generate responses from different LLM providers and automatically store the messages in one seamless operation.

Efficiency

Streamline your workflow by generating and storing messages in a single step. This integrated approach saves time and reduces complexity in your code.

Comprehensive Tracking

Automatically store all generated messages for easy tracking, analysis, and auditing. Ensure no important information is lost in the process.

In this mode, you get the benefits of both the generate and store modes:

  • Analyze Data: Use the stored data to control costs and optimize AI.
  • Standardized Format: Standardize LLM responses for easy analysis.
  • Unified API: One API for all LLM providers.
  • No Vendor Lock-in: Easily switch between various providers.

Prerequisites

Make sure to install the SDK of the providers you want to use:

yarn add openai
yarn add @anthropic-ai/sdk

Generate and store a message

By default when creating a new message using the create method, the message is generated and stored automatically. You can either provide a custom callback function to recieve the structured message and store it in your database, or use Lira’s built-in storage (and Dashboard) to store the message.

Check out the Store mode for more information on how to configure the store.

import { Lira } from 'lira'

const lira = new Lira()

const res = await lira.message.create()