TypeScript Minimal App
This example is meant to verify three things first:
- The AgentOS gateway is reachable
- SDK initialization and bundle registration work
- ModelKit chat returns a valid response
If you are using an AI coding tool, treat this page more like reference truth than a long tutorial.
If the generated code disagrees with the docs, come back here and compare against the minimal skeleton first.
Recommended prompt
text
Use the AgentOS TypeScript minimal example as the reference shape and generate a minimal integration in my project that stays as close to that structure as possible.
Requirements:
- Use agentos-sdk-ts
- Register the bundle first
- Subscribe a minimal event handler next
- Then call modelkit.chat.create for one minimal message request
- Preserve the example order and code skeleton as much as possible
- If a model name is needed, prefer an environment variable plus a fallbackExample code
Source example: agentos-sdk-ts/example/agentos_sdk_example.mjs
ts
import { AgentOSEventHandler, AgentOSSDK, ModelTask } from 'agentos-sdk-ts';
const sdk = new AgentOSSDK({
baseUrl: process.env.AGENTOS_BASE_URL ?? 'http://127.0.0.1:8888'
});
class DemoEventHandler extends AgentOSEventHandler {
async onWelcome(welcome) {
console.log('Welcome bundleId:', welcome.bundleId);
}
}
async function main() {
await sdk.agentos.registerBundle({
bundleId: 'com.example.minimal.ts',
appGroupId: 'com.example.minimal'
});
await sdk.agentos.subscribe(new DemoEventHandler());
const models = await sdk.modelkit.listModelsByTask(ModelTask.chat);
const completion = await sdk.modelkit.chat.create({
model: process.env.AGENTOS_LLM_MODEL ?? models[0]?.id ?? 'qwen3-1.7b',
messages: [
{
role: 'user',
content: 'Say hello from the TypeScript minimal app.'
}
]
});
console.log(completion.choices?.[0]?.message?.content);
}
main().catch(console.error);How to run it
bash
npm install agentos-sdk-ts
AGENTOS_BASE_URL=http://127.0.0.1:8888 node app.mjsWhat you should see
- bundle registration succeeds without auth errors
- the SSE subscription is established successfully
- the terminal prints one visible model-generated text response
AI mistakes to watch for
- Skipping
registerBundle(...)and assuming a token already exists - Treating AgentOS as the default OpenAI endpoint instead of a separate gateway
- Inventing SDK initialization parameters or event names that do not exist
- Adding extra abstraction before the minimal path is verified
Manual verification checklist
- Does the structure still look like
SDK init -> registerBundle -> subscribe -> chat.create? - Does it support configuring the gateway through
AGENTOS_BASE_URL? - Does it print at least one visible model response?
