Create your first agent
Read fields from a short order, then inspect the input, result and tokens in the dashboard.
1. Create an agent
Open the dashboard, choose your Space and create an agent. Name it Order reader, choose an available model and use these instructions:
Read order details from the supplied text.
Use only stated facts. Do not invent missing values.Copy the agent ID. The examples below use order-reader; replace it with the ID shown in your dashboard.
2. Connect from your backend
Open Connect on the agent. As an Owner, choose Create a key and copy it immediately; the full key stays visible only until you leave the agent page. Editors should ask an Owner for a key. Put it in your backend environment as NULLPROTOCOL_KEY.
npm install nullprotocol@3.4.0
export NULLPROTOCOL_KEY='your-space-sdk-key'3. Run a request
Use Node.js 18 or newer. Save this as agent.mjs:
import { NullProtocol } from 'nullprotocol';
const agent = await NullProtocol.load({
key: process.env.NULLPROTOCOL_KEY,
agentId: 'order-reader'
});
const result = await agent.extract(
'Order 42: two blue mugs.',
{ orderId: 'number', quantity: 'number', item: 'string' }
);
if (!result.success) {
console.error(result.errorCode, result.error);
process.exitCode = 1;
} else {
console.log(result.data);
console.log(result.usage);
}
if (result.historyError) {
console.error('History was not saved:', result.historyError);
}node agent.mjsWith a successful extraction, result.data contains the order ID, quantity and item. result.usage contains input and output tokens when the provider reports them. The same Space key authorizes the saved agent and its model; you do not need a separate provider key.
Keep the client available for your calls
Load a saved agent once per application component and reuse it for calls. Its saved settings are read for each operation.
Use it in an async application
import { NullProtocol } from 'nullprotocol';
async function readOrder() {
const agent = await NullProtocol.load({
key: process.env.NULLPROTOCOL_KEY, agentId: 'order-reader'
});
return agent.extract('Order 42: two blue mugs.', { orderId: 'number' });
}
const result = await readOrder();
console.log(result.success ? result.data : result.error);SDK network methods return promises. Use await inside an async function or an ES module.
4. Inspect it and change a rule
Open the agent’s History and refresh the list. Open the operation to see its input, output, model, instructions, included context and reported usage.
Edit the agent’s instructions or add a short rule under Context. Run the file again. The next operation uses the saved changes without changing your application code.