Skip to main content
const { prompts } = await tracia.prompts.list();
Retrieve all prompts associated with your account, ordered by most recently updated.

Parameters

This method takes no parameters.

Response

interface PromptListItem {
  id: string;
  slug: string;
  name: string;
  description: string | null;
  model: string | null;
  currentVersion: number;
  variables: string[];
  createdAt: string;
  updatedAt: string;
}

Examples

Basic Usage

const { prompts } = await tracia.prompts.list();

console.log(`Found ${prompts.length} prompts`);

Iterating Over Prompts

const { prompts } = await tracia.prompts.list();

prompts.forEach(prompt => {
  console.log(`${prompt.name} (${prompt.slug}) - v${prompt.currentVersion}`);
  console.log(`  Variables: ${prompt.variables.join(', ') || 'none'}`);
});

Filtering Prompts

const { prompts } = await tracia.prompts.list();

// Find prompts with specific variables
const emailPrompts = prompts.filter(p =>
  p.variables.includes('email')
);

// Find prompts using a specific model
const gpt4Prompts = prompts.filter(p =>
  p.model === 'gpt-4'
);

Error Handling

import { TraciaError, TraciaErrorCode } from 'tracia';

try {
  const { prompts } = await tracia.prompts.list();
} catch (error) {
  if (error instanceof TraciaError) {
    if (error.code === TraciaErrorCode.UNAUTHORIZED) {
      console.error('Invalid API key');
    }
  }
}