Cleanup Instances
Copy
const instance = await Instance.create({
name: 'my-session',
description: 'Session'
});
try {
await instance.run('Task 1');
await instance.run('Task 2');
} finally {
await instance.destroy(); // Always cleanup
}
Reuse Templates
Copy
const client = new In10ntClient();
// Check if template exists before creating
const templates = await client.templates.list();
let template = templates.find(t => t.name === 'python-ml');
if (!template) {
template = await client.templates.create({
name: 'python-ml',
image: 'python:3.11-slim',
registryType: 'dockerhub'
});
await template.waitUntilReady();
}
Error Handling
Copy
import { Instance, In10ntError, TimeoutError, HealthCheckError } from '@in10nt/sdk';
try {
await instance.run('Build something');
} catch (error) {
if (error instanceof TimeoutError) {
console.error('Task timed out');
} else if (error instanceof HealthCheckError) {
console.error('Instance not healthy');
} else if (error instanceof In10ntError) {
console.error(`API error (${error.statusCode}):`, error.message);
}
}
Use Environment Variables
Copy
# .env
IN10NT_API_KEY=your_key
Copy
// Zero-config — reads IN10NT_API_KEY automatically
import { Instance } from '@in10nt/sdk';
const instance = await Instance.create({
name: 'my-agent',
description: 'Agent'
});
Never commit
.env to git. Add to .gitignoreCost Optimization
Copy
// Reuse one instance for multiple tasks
const instance = await Instance.create({
name: 'session',
description: 'Multi-task session'
});
await instance.run('Task 1');
await instance.run('Task 2');
await instance.run('Task 3');
await instance.destroy();
Set Timeouts
Copy
await instance.run('Complex task', {
timeout: 120_000 // 2 min max
});
Monitor Usage
Copy
const client = new In10ntClient();
const usage = await client.usage.getTokenUsage();
if (usage.monthlyCost > 100) {
console.warn('Cost threshold exceeded');
}
Naming
Copy
// Clear names
'user-api-builder'
'python-ml-v2'
'discord-bot-prod'
// Avoid vague names
// 'inst1', 'tmpl', 'test'
Performance
Copy
// Parallel creation (fast)
const [inst1, inst2, inst3] = await Promise.all([
Instance.create({ name: 'agent-1', description: 'Agent 1' }),
Instance.create({ name: 'agent-2', description: 'Agent 2' }),
Instance.create({ name: 'agent-3', description: 'Agent 3' })
]);
Logger
Copy
import { In10ntClient, createConsoleLogger } from '@in10nt/sdk';
// Opt-in to debug logging
const client = new In10ntClient({ logger: createConsoleLogger() });
// Or pass any logger with { debug, info, warn, error }
const client = new In10ntClient({ logger: myLogger });
Security
- Never log API keys
- Use env vars for secrets
- Rotate keys regularly
- Separate dev/prod keys

