Skip to content

Implementation guide

TypeScript quickstart

Install the TypeScript SDK, create an agent from Node.js, and read its first result.

Browse developer docs

Current: TypeScript quickstart

Install and authenticate

These examples target SDK 0.2.x, which is published on npm, and the unified v2 backend. See version and availability. Use Node.js 20.9+. Set AGENTRUN_API_KEY on your server.

bash

npm install @parcha/[email protected]

Pin the version your integration was reviewed against.

Build and run

typescript

import { Agent } from '@parcha/agentrun';
const agent = await Agent.create({
  apiKey: process.env.AGENTRUN_API_KEY!,
  baseURL: 'https://api.grep.ai/api/v2',
  prompt: 'Research companies and cite primary sources.',
});
console.log('Save build ID:', agent.buildId);
await agent.waitUntilReady();
console.log('Save agent ID:', agent.id);
const run = await agent.run('Research example.com', { idempotencyKey: 'example-001' });
console.log('Save run ID:', run.id);
const result = await agent.wait(run.id);
if (result.status === 'completed') console.log(result.report?.markdown);
else console.log('Run ended:', result.status);

Build generation can take several minutes. Save IDs as soon as they are returned. A wait returning does not imply success; inspect the status. Local timeouts do not stop remote work.

Reuse an agent

typescript

const saved = new Agent({ apiKey: process.env.AGENTRUN_API_KEY!, id: 'YOUR_AGENT_ID' });
const next = await saved.run('Research another company', { idempotencyKey: 'example-002' });

Reuse a stable idempotency key for a retry of the same logical submission. Use a new key for new work. See the typescript reference and errors guide.