Quickstart

Install the Coresource SDK, set your API key, and run your first agent. Pick your setup: SDK, Claude Code, or Codex.

1Install and authenticate

The SDK is ESM-only, so use import, not require. Every entry point reads CORESOURCE_API_KEY from the environment.

npm install @coresourceai/sdk
export CORESOURCE_API_KEY='your-api-key'

To pass the key explicitly, point at another deployment, or supply your own fetch, see Authentication.

2Define an agent

createAgent is synchronous and lazy — it does no network work until run() or start(). Nothing is validated against the server at construction time.

reconcile.ts
import { createAgent } from '@coresourceai/sdk';

const agent = createAgent({
  type: 'saga',
  model: 'deepseek/deepseek-v4-flash',
  effort: 'xhigh',
  systemPrompt: `You reconcile invoices against the ledger.
Follow the field rules exactly, and never invent a value
a source system did not state.`,
  outputs: ['report.md']
});

const result = await agent.run('Reconcile last quarter and flag exceptions.');
console.log(result.text);

The model line names where the router starts; it escalates to premium models when your plan allows. Learn how to choose an agent type in Agent types.

3Watch it run

run() waits for the final result, which is right for a script and wrong when a person is watching. start() returns as soon as the run exists and events() streams what it is doing.

const codingAgent = createAgent({ type: 'agent' });

// file_read, file_write, file_edit, glob, grep, web_fetch, execute
codingAgent.registerRuntimeTools();

Continue with Running agents (files, artifacts, cancellation) or Tools to give an agent your database or browser.