SynthForge SynthForge SynthForge IO

Docs · TypeScript SDK

TypeScript SDK

@synthforgeio/sdk wraps the REST API with typed methods and polling helpers.

Before you start: you need a personal API key. Create one in the app, then come back.

@synthforgeio/sdk is a thin typed client for schemas, AI schema generation, and datasets. On npm: npm install @synthforgeio/sdk. MIT licensed, zero runtime dependencies. The helpers create the job, wait for it to finish, and throw a typed error if it fails.

typescript
// npm install @synthforgeio/sdk
import { SynthForge } from '@synthforgeio/sdk';

const sf = new SynthForge({
  apiKey: process.env.SF_API_KEY!, // sfk_…
});

// One call: a schema from the description, then a dataset from the schema.
const result = await sf.descriptionToDataset({
  description: 'customers with orders; each customer places 1 to 5 orders',
  default_rows: 500,
  formats: ['csv'],
  includeDownloadUrl: true,
});
console.log(result.downloadUrl);

// Or two steps, to read the schema before any rows are generated.
const drafted = await sf.generateSchema({
  description: 'a lending library: members, books, and loans',
});
console.log(drafted.schema.schema_data);

const { downloadUrl } = await sf.generateDataset({
  schema_id: drafted.schemaId,
  default_rows: 200,
  includeDownloadUrl: true,
});

Each resource is also there on its own, when you want to drive the steps yourself:

typescript
const { items } = await sf.schemas.list({ limit: 20 });

const schema = await sf.schemas.create({
  name: 'orders',
  schema_data: {
    tables: [
      {
        name: 'orders',
        columns: [
          { name: 'id', field_type: 'uuid', primary_key: true },
          { name: 'label', field_type: 'word' },
        ],
      },
    ],
  },
});

const dataset = await sf.datasets.create({
  schema_id: schema.id,
  name: 'demo',
  row_counts: { orders: 100 },
  formats: ['csv'],
  seed: 42,
});

const status = await sf.datasets.wait(dataset.id);
if (status.status === 'completed') {
  const { url } = await sf.datasets.getDownloadUrl(dataset.id);
  // fetch(url) → ZIP
}

Next