JavaScript Code Generation

Overview

Circuitry generates modern JavaScript (ES modules) code from visual workflows that runs in Node.js.

Requirements

  • Node.js 18+ (uses the built-in fetch API)
  • No npm packages required - uses built-in APIs
  • API Keys - Pass via options.apiKey or set the OPENAI_API_KEY / ANTHROPIC_API_KEY environment variables

Quick Start

import { httpRequest, callAI, replaceTemplateVariables } from './circuitry-helpers.js';

// OpenAI (uses OPENAI_API_KEY from the environment if apiKey is omitted)
const gptResponse = await callAI("Hello!", {
  model: "gpt-4o",
  systemPrompt: "You are a helpful assistant.",
  temperature: 0.7
});

// Anthropic Claude (models containing "claude" route automatically;
// uses ANTHROPIC_API_KEY from the environment if apiKey is omitted)
const claudeResponse = await callAI("Hello!", {
  model: "claude-opus-4-8",
  maxTokens: 1024
});

// Local or self-hosted model with an OpenAI-compatible endpoint
const localResponse = await callAI("Hello!", {
  endpoint: "http://localhost:11434/v1/chat/completions",
  model: "llama3"
});

// HTTP request (JSON responses are parsed automatically)
const data = await httpRequest("https://api.example.com/items", {
  method: "POST",
  body: { name: "example" }
});

// Resolve {{input}} / {{input.path.to.value}} template variables
const text = replaceTemplateVariables("Hello {{input.user.name}}", {
  user: { name: "Ada" }
});