Why use the generate mode?

You can use the generate mode to generate responses from different LLM providers using the same API. This mode is ideal for scenarios where you want to generate responses from different LLM providers without storing the messages.

Unified API

Same API for all supported LLM providers. Switch between providers without changing a single line of code. Our API abstracts provider differences, ensuring uniform input and output formats across all providers.

No vendor lock-in

Easily switch between various providers without vendor lock-in. The unified interface abstracts away differences between provider APIs, allowing seamless changes between various LLMs.

Prerequisites

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

yarn add openai
yarn add @anthropic-ai/sdk

Generate without storing

When creating a new message, you can use the create method to generate a response from the LLM provider. By default the storing option is enabled, which means the message request and response will be stored (Store mode). To disable storing the message, you can set the store.disabled option to true.

Disable storing globally

import { Lira } from 'lira'

const lira = new Lira({
  store: {
    disabled: false,
  },
})

const res = await lira.message.create()

Disable storing per-request

import { Lira } from 'lira'

const lira = new Lira()

const res = await lira.message.create({
  lira: {
    store: {
      disabled: false,
    },
  },
})

See the SDK references for more details.