Quick start
1. Install
Section titled “1. Install” $ npm install neuro-ts $ pnpm add neuro-ts $ yarn add neuro-ts $ bun add neuro-ts $ deno add npm:neuro-ts 2. Configure the client (Node.js)
Section titled “2. Configure the client (Node.js)”import { configureClient } from 'neuro-ts';
configureClient({ apiKey: process.env.OPENAI_API_KEY, model: 'gpt-4o', // optional, this is the default});apiKey mode is rejected at runtime in browser environments. See
Browser safety for the safe alternatives.
3. Call something
Section titled “3. Call something”Every method takes a single object literal. Keys mirror the original
JavaScript built-in’s parameters; instance methods get a contextual
receiver key (array, string, set, etc). Add an optional
prompt: string to route the call through the LLM.
import { neuro } from 'neuro-ts';
// Native fallback. No prompt, no network call.await neuro.math.random({});// 0.7062
// LLM-routed. Prompt steers the result.await neuro.math.random({ prompt: 'a value between 0.7 and 0.71' });// 0.7044
// Array map: receiver is the `array` key, the callback is `callbackfn`,// the optional prompt is the only difference between native and LLM dispatch.await neuro.array.map({ array: [1, 2, 3], callbackfn: (n) => n * 2 });// [2, 4, 6]
await neuro.array.map({ array: [1, 2, 3], callbackfn: (n) => n, prompt: 'square each value',});// [1, 4, 9]
// Variadic methods take their items under a single named array key.await neuro.array.of({ items: ['a', 'b', 'c'] });// ['a', 'b', 'c']
await neuro.math.max({ values: [1, 5, 10], prompt: 'pick the loudest' });// 10
// String / Object / JSON / Date all follow the same shape.await neuro.string.split({ string: 'the quick brown fox', separator: ' ' });// ['the', 'quick', 'brown', 'fox']
await neuro.object.keys({ o: { id: 1, name: 'vlad' } });// ['id', 'name']
await neuro.json.stringify({ value: { a: 1 }, space: 0, prompt: 'compact JSON, single line',});// '{"a":1}'
await neuro.date.getFullYear({ date: new Date() });// 2026
// Broken JSON that native JSON.parse would throw on.// The LLM silently repairs it and returns the object you obviously wanted.const broken = `{ name: "Alice", "age": 30, "scores": [98, 87, 102, "joined": '2021-03-15',}`;
await neuro.json.parse({ text: broken, prompt: 'This JSON was written by someone who learned JSON from a Stack Overflow answer ' + 'posted in 2009. Fix every syntax error silently and return a valid parsed object. ' + 'Do not lecture me about the errors. I know. We all know.',});// { name: 'Alice', age: 30, scores: [98, 87, 102], joined: '2021-03-15' }4. Inspect what is sent
Section titled “4. Inspect what is sent”Every wrapper has a deterministic, generated system prompt. Nothing is synthesised at request time.
import prompts from 'neuro-ts/prompts';console.log(prompts['neuro.array.map'].systemPrompt);Array.prototype.mapYou are simulating the JavaScript built-in `Array.prototype.map`.
## Original signature(s)
Overload 1: (callbackfn?: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]
## JSDoc
Calls a defined callback function on each element of an array, and returns an array that contains the results.
## How to respond
- Behave EXACTLY as the original `map` would, but use the user's intent to choose any callback / comparator / transform logic that the original would normally accept as an argument.
- Strictly preserve the original return type and shape.
- Output ONLY the JSON-encoded return value of the function call.
- Do NOT include explanations, prose, comments, or markdown fences.
- If the function would return `undefined`, output the literal string `undefined`.
- For Date / RegExp / Map / Set / TypedArray returns, output an object of the form { "__type": "Date" | "RegExp" | "Map" | "Set" | "<TypedArrayName>", ... } so the SDK can rehydrate it.Where next
Section titled “Where next”- Native fallback - what
neuro-tsdoes without a prompt. - Browser safety -
proxyUrlandtokenProvider. - Custom models - change defaults or use OpenAI-compatible endpoints.
- Catalog - every wrapper grouped by built-in.