Skip to main content
POST
/
api
/
v1
/
prompts
/
{slug}
/
run
curl -X POST https://app.tracia.io/api/v1/prompts/welcome-email/run \
  -H "Authorization: Bearer tr_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "variables": {
      "name": "Alice",
      "product": "Tracia"
    },
    "tags": ["onboarding", "email"],
    "userId": "user_123"
  }'
{
  "text": "Dear Alice,\n\nWelcome to Tracia! We're thrilled to have you join our community...",
  "traceId": "tr_abc123xyz",
  "promptVersion": 3,
  "latencyMs": 1250,
  "usage": {
    "inputTokens": 45,
    "outputTokens": 120,
    "totalTokens": 165
  },
  "cost": 0.0049
}
Run a prompt with variable substitution and get the generated response. This endpoint handles template rendering, LLM API calls, and automatically logs a trace.

Request

Authorization
string
required
Bearer token with your API key: Bearer tr_your_api_key
slug
string
required
The prompt slug to run
variables
object
Key-value pairs for template variables. Must include all variables required by the prompt.
model
string
Override the default model (e.g., gpt-4, claude-3-opus-20240229)
tags
string[]
Tags for filtering traces in the dashboard
userId
string
End user identifier for tracking
sessionId
string
Session identifier for grouping related traces

Response

text
string
The generated text from the LLM
traceId
string
Unique identifier for this trace (use to look up in dashboard)
promptVersion
number
Version of the prompt that was used
latencyMs
number
Total request latency in milliseconds
usage
object
Token usage statistics
cost
number
Estimated cost in USD
curl -X POST https://app.tracia.io/api/v1/prompts/welcome-email/run \
  -H "Authorization: Bearer tr_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "variables": {
      "name": "Alice",
      "product": "Tracia"
    },
    "tags": ["onboarding", "email"],
    "userId": "user_123"
  }'
{
  "text": "Dear Alice,\n\nWelcome to Tracia! We're thrilled to have you join our community...",
  "traceId": "tr_abc123xyz",
  "promptVersion": 3,
  "latencyMs": 1250,
  "usage": {
    "inputTokens": 45,
    "outputTokens": 120,
    "totalTokens": 165
  },
  "cost": 0.0049
}