Native fallback
Every neuro.* method has two modes, decided at the call site by the
presence of a prompt key on the input object:
prompt field | Behaviour |
|---|---|
| Missing | Calls the native built-in directly. |
Empty string '' | Treated as missing - calls the native built-in directly. |
| Non-empty string | Routes to the configured LLM. |
The native fallback is not a fallback in the “the LLM failed, fall back” sense. It is the default. The LLM is opt-in per call.
import { neuro } from 'neuro-ts';
await neuro.array.map({ array: [1, 2, 3], callbackfn: (n) => n * 2 });// [2, 4, 6] <- native call, no client needed
await neuro.string.split({ string: 'a,b,c', separator: ',' });// ['a', 'b', 'c'] <- native
await neuro.object.keys({ o: { a: 1, b: 2 } });// ['a', 'b'] <- nativeWhy both?
Section titled “Why both?”The native path keeps neuro-ts a strict superset of the standard library.
You can wire neuro into existing code, ship it without breaking anything,
then sprinkle prompts in only where they help.
It also means neuro-ts works with no OPENAI_API_KEY configured: as long
as the input lacks a prompt field, the library is just a typed Promise
wrapper over the original built-ins.
Is it zero-cost?
Section titled “Is it zero-cost?”Yes. The native fallback is a synchronous call to the original built-in
wrapped in Promise.resolve(). There is no network round-trip, no client
instantiation, and no parsing overhead beyond the argument object lookup.
Does it require configureClient?
Section titled “Does it require configureClient?”No. Native fallback calls never touch the client singleton. You can use
neuro.* without calling configureClient() as long as you omit prompt:
import { neuro } from 'neuro-ts';
// Works with no configureClient() call at all.const sorted = await neuro.array.sort({ array: [3, 1, 2] });// [1, 2, 3]Only calls with a non-empty prompt require the client to be configured.
What if the native built-in throws?
Section titled “What if the native built-in throws?”Errors from the native built-in propagate as-is. neuro-ts does not catch
or wrap them on the fallback path:
await neuro.json.parse({ text: 'not valid json' });// SyntaxError: Unexpected token 'o', "not valid json" is not valid JSONThis is intentional — the native fallback behaves exactly like calling
the original built-in directly. If you want error recovery, use a prompt:
await neuro.json.parse({ text: 'not valid json', prompt: 'fix any syntax errors and parse',});Every method supports a prompt
Section titled “Every method supports a prompt”Every one of the 673 wrappers accepts an optional prompt field and
routes to the LLM when one is supplied. There are no native-only methods.
The only thing that changes is whether the result the LLM produces makes
sense for the method’s return type — iterators, live WeakMap handles,
and atomic operations that depend on shared memory state cannot be
serialised over the wire, so for those methods you almost always want
the native path. Pick whichever suits the call.