Skip to content

Implementation guide

TypeScript quickstart

Install the SDK, create an agent, and read a result.

Browse developer docs

Current: TypeScript quickstart

Install and authenticate

These examples target SDK 0.2.0 and require the unified v2 backend. See release availability. Use Node.js 20.9+. Set AGENTRUN_API_KEY on your server.

bash

npm install @parcha/[email protected]

This version-specific registry command becomes available after release. Before release, install the reviewed tarball with npm install ./parcha-agentrun-0.2.0.tgz.

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.