Initialization & the core calls
Install the SDK, call init once, then use the two calls you'll reach for everywhere: get to fetch a prompt by name, and compile to fill its variables locally.
Two calls carry the whole workflow: get fetches a prompt by name and hands you the entire thing, and compile fills its variables locally and returns a ready-to-send payload. Everything else is configuration. This page gets you from install to a real provider call.
Install
npm install trodo-node@^2.23.4pip install trodo-pythonInitialize once
Call init once at startup with your site id. Every prompt method lives on the singleton afterward: you don't pass credentials again.
import trodo from 'trodo-node';
trodo.init({
siteId: process.env.TRODO_SITE_ID!,
// apiBase: 'https://sdkapi.trodo.ai', // default
// timeout: 5000,
// retries: 2,
// debug: false,
});import trodo
trodo.init(
site_id=os.environ["TRODO_SITE_ID"],
# api_base="https://sdkapi.trodo.ai", # default
# timeout=5000,
# retries=2,
# debug=False,
)| Option | Default | Notes |
|---|---|---|
siteId / site_id | Required. Identifies and authenticates your team. | |
apiBase / api_base | https://sdkapi.trodo.ai | Override to point at a self-hosted or staging API. |
timeout | 5000 | Default per-request timeout in ms. |
retries | 2 | Default network retries before falling back. |
debug | false | Log resolution and cache decisions. |
get, fetch the whole prompt
get resolves a prompt by name and returns a ManagedPrompt: its messages (still holding {{vars}}), model config, tools, output format, and variable declarations. By default it follows the production label; pin a specific label or version when you need to.
const prompt = await trodo.prompts.get('refund-agent');
// prompt.messages, prompt.model, prompt.tools, prompt.response_format, prompt.variablesprompt = trodo.get_prompt("refund-agent")
# prompt.messages, prompt.model, prompt.tools, prompt.response_format, prompt.variablesSee Version control for label and version resolution, and Caching & availability for the fallback and TTL options that keep this call resilient.
compile, fill the variables locally
compile runs locally, with no network call. It renders only the messages, filling every {{var}} and injecting any placeholder message-lists, and passes model, tools, and response_format through unchanged. It returns a CompiledPrompt of { messages, model, tools, response_format }.
const { messages, model, tools, response_format } = prompt.compile({
company: 'Acme',
question: 'where is my order?',
});compiled = prompt.compile(
company="Acme",
question="where is my order?",
)
# compiled.messages, compiled.model, compiled.tools, compiled.response_formatA missing value is never an error: it renders the variable's declared default, or empty. Passing a variable the prompt does not declare throws CompileError, listing every offending key, before any model call. See Variables & templating.
End to end
Init, fetch, compile, and hand the result to your provider. The model config is a versioned recommendation, read model.model and pass it to your client yourself.
import trodo from 'trodo-node';
import OpenAI from 'openai';
trodo.init({ siteId: process.env.TRODO_SITE_ID! });
const openai = new OpenAI();
const prompt = await trodo.prompts.get('refund-agent');
const { messages, model } = prompt.compile({
company: 'Acme',
question: 'where is my order?',
});
const answer = await openai.chat.completions.create({
model: model.model ?? 'gpt-4o',
temperature: model.temperature ?? 0.2,
messages,
});import os, trodo
from openai import OpenAI
trodo.init(site_id=os.environ["TRODO_SITE_ID"])
openai = OpenAI()
prompt = trodo.get_prompt("refund-agent")
compiled = prompt.compile(
company="Acme",
question="where is my order?",
)
answer = openai.chat.completions.create(
model=compiled.model.get("model", "gpt-4o"),
temperature=compiled.model.get("temperature", 0.2),
messages=compiled.messages,
)Two more calls
list returns lightweight summaries of every prompt on your team, { name, description, version, labels, updatedAt }, with no message content. It returns [] on error rather than throwing, so it's safe to call on a dashboard route.
const prompts = await trodo.prompts.list();prompts = trodo.list_prompts()renderTemplate exposes the same rendering engine compile uses, standalone, for reusing the exact production rendering on a string you already have. It's strict by default (an unknown variable raises); pass strict: false / strict=False to render unknowns as empty.
import { renderTemplate } from 'trodo-node';
renderTemplate('Hi {{name}}', { name: 'Ada' }); // 'Hi Ada'
renderTemplate('Hi {{name}}', {}, { strict: false }); // 'Hi 'from trodo import render_template
render_template("Hi {{name}}", name="Ada") # 'Hi Ada'
render_template("Hi {{name}}", strict=False) # 'Hi 'Where to go next
Concepts
Everything conceptual in one place: prompts, versions, labels, tags, variables, placeholders, the get/compile split, the exact data shapes, version resolution, and how caching keeps a fetch off your critical path.
Initialization & the core calls
Install the SDK, call init once, then use the two calls you'll reach for everywhere: get to fetch a prompt by name, and compile to fill its variables locally.