Create your first agent
Start with the work you want to repeat: the instructions, evidence, tools, and output format. Build once, save the agent ID, and reuse it for every new input.
Create, run, reuse
create-agent.tstypescript
import { Agent } from '@parcha/agentrun';
const agent = await Agent.create({
apiKey: process.env.AGENTRUN_API_KEY!,
baseURL: process.env.AGENTRUN_API_BASE!,
prompt: 'Extract invoice numbers, totals, and due dates. Return JSON and flag missing fields.',
});
await agent.waitUntilReady();
console.log('Save this agent ID:', agent.id);
const run = await agent.run('Invoice INV-1042. Total USD 250. Due 2026-10-15.');
const result = await agent.wait(run.id);
console.log(result);Set your API key and the base URL for your AgentRun-enabled deployment before running this example. The quickstart covers setup, build completion, and reuse.
Build with the agent primitives
| Primitive | Use it for |
|---|---|
| Agents | Reusable instructions, skills, tools, and output requirements. |
| Runs | One execution of an agent on a new input. |
| Skills | Reusable methods that agents apply to the job. |
| Batches | The same agent across many inputs. |
| Loops | Repeat work on a schedule and watch for changes. |
| Campaigns | Connect multiple agents and pass results between stages. |