Lytix helps manage prompts directly in the CLI using our lytix cli commands.

Note We currently only support Typescript/Javascript.

🚨 Prerequisite Login & setup your lytix CLI here.

Sync your prompts (e.g. git pull your prompts)

Now you can sync your prompts to your local machine. This is the equivalent of git pull for your prompts.

If there are changes that are uncommited or would cause a conflict, you will be prompted to resolve them. You can pass the --force flag to skip this check and overwrite your local changes.

lytix prompt sync

Create a new prompt

Now let’s create our first prompt. All you need to get started is a prompt name.

lytix prompt create --promptName "my new prompt"

Edit & Use The Prompt

Now let’s iterate on our prompt and start using it.

Add Variables

Lytix supports adding templated variables to your prompts. This allows you to dynamically pass in variables when you use the prompt and get type safety as lytix will generate a .ts types file for you based on the inputs

Inside prompt.json, the variables field is where you can add your variables. It supports:

  • type: STRING | NUMBER | BOOLEAN - The type of the variable
  • name: The name of the variable

For example, a prompt.json file with a toEcho variable might look like this:

{
    ...
    "variables": [
        {
      "type": "STRING",
      "name": "toEcho"
    }
  ]
}

Commit Changes

Now you’re ready to commit changes (e.g. git commit && git push).

Note This will immediately update the prompt and any incomming requests using the promptId

lytix prompt commit

Pass promptId & Use Prompt

⚠️ Important You need to use the v2 baseURL: https://api.lytix.co/proxy/v2/openai. Please follow instructions here to setup the lytix OpenAI integration.

Now you are to use the lytixPromptId to start using your prompt. You can now pass an empty messages array and add the lytixPromptId & lytixPromptVariables to your request:

const client = new OpenAI({
  apiKey: LYTIX_API_KEY,
  baseURL: "https://api.lytix.co/proxy/v2/openai";,
  defaultHeaders: {
    anthropicApiKey: ANTHROPIC_API_KEY,
    openaiKey: OPENAI_API_KEY,
  },
});

/**
 * This is dyntamically generated type based on the prompt variables defined in `prompt.json`. 
 * Run `lytix prompt sync` to update them
 */
const inputVariables: my_new_promptInput = {
  toEcho: "This is coming from the lytix variable!",
};

const response = await client.chat.completions.create({
    model: "gpt-4o-mini",
    messages: [],
    // @ts-expect-error lytix variables
    lytixPromptId: "464df7b9-81bf-435e-96ba-b95eab905452", // This promptId comes from the `prompt.json` file
    lytixPromptVariables: inputVariables,
});

Delete a prompt

Once you are ready to delete a prompt, you can do so with the following command:

lytix prompt delete --promptName "my new prompt"