Prerequisites
- A Tracia account (sign up)
- Node.js 18 or later
- An API key from a supported LLM provider (OpenAI, Anthropic, etc.)
Step 1: Get Your API Key
- Log in to tracia.io
- Navigate to Settings > API Keys
- Click Create API Key
- Copy your key (starts with
tr_)
Store your API key securely. It provides full access to your Tracia account.
Step 2: Install the SDK
- Go to Settings > Providers in the Tracia dashboard
- Add your OpenAI, Anthropic, or other provider API key
- Tracia encrypts and stores your key securely
Step 4: Create Your First Prompt
- Go to Prompts in the dashboard
- Click New Prompt
- Enter a name (e.g., “Welcome Email”)
- Add your prompt messages:
System: You are a helpful assistant that writes professional emails.
User: Write a welcome email for {{name}} who just signed up for {{product}}.
- Click Save
Use {{variable}} syntax to create dynamic prompts. Variables are replaced at runtime.
Step 5: Run Your Prompt
import { Tracia } from 'tracia';
const tracia = new Tracia({
apiKey: process.env.TRACIA_API_KEY
});
const result = await tracia.prompts.run('welcome-email', {
name: 'Alice',
product: 'Tracia'
});
console.log(result.text);
// Output: "Dear Alice, Welcome to Tracia!..."
console.log(result.usage);
// { inputTokens: 45, outputTokens: 120, totalTokens: 165 }
Step 6: View Traces
After running your prompt:
- Go to Traces in the dashboard
- See the full execution details including:
- Input/output content
- Token usage and cost
- Latency metrics
- Variables used
Next Steps