In this example, we will use the static ContextMode, which begins with an initial list of messages defining the base context of the conversation, such as predefined instructions. Unlike dynamic mode, this context is fixed and does not evolve with new messages. Each inference request is processed independently, using only the initial context and the latest input, without retaining any previous conversation history.
Make a new project folder
Install dependencies
pnpm add typescript ts-node @types/node -D
pnpm add @trymirai/uzu
Initialize a tsconfig.json
{
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"moduleResolution": "node",
"strict": true,
"esModuleInterop": true,
"outDir": "dist",
"types": [
"node"
]
},
"include": [
"*.ts"
]
}
Create main.ts
Don’t forget to add your API key.
import Engine, { Config, ContextMode, Input, Message, RunConfig } from '@trymirai/uzu';
function listToString(list: string[]): string {
return "[" + list.map((item) => `"${item}"`).join(", ") + "]";
}
async function main() {
const engine = await Engine.load('API_KEY');
const model = await engine.chatModel('Qwen/Qwen3-0.6B');
await engine.downloadChatModel(model, (update) => {
console.log('Progress:', update.progress);
});
const instructions =
`Your task is to name countries for each city in the given list.
For example for ${listToString(["Helsenki", "Stockholm", "Barcelona"])} the answer should be ${listToString(["Finland", "Sweden", "Spain"])}.`;
const config = Config
.default()
.withContextMode(ContextMode.static(Input.messages([Message.system(instructions)])));
const session = engine.chatSession(model, config);
const requests = [
listToString(["New York", "London", "Lisbon", "Paris", "Berlin"]),
listToString(["Bangkok", "Tokyo", "Seoul", "Beijing", "Delhi"]),
];
const runConfig = RunConfig
.default()
.withEnableThinking(false);
for (const request of requests) {
const output = session.run(Input.text(request), runConfig, (partialOutput) => {
return true;
});
console.log('Request:', request);
console.log('Response:', output.text.original.trim());
console.log('-------------------------');
}
}
main().catch((error) => {
console.error(error);
});
Now that we’ve tried the simplest snippet, let’s take a look at the step-by-step integration guide.