Skip to content

Install

neuro-ts is published to npm. It ships ESM, CJS, an IIFE bundle for direct script tags, and full TypeScript types.

$ npm install neuro-ts
RuntimeMinimum
Node18.18
Bun1.0
Modern browsersES2022

The openai SDK is a runtime dependency. It is not bundled into the ESM/CJS outputs (treeshaking-friendly). It is inlined into the IIFE bundle so a single script tag works on a static page.

neuro-ts ships full .d.ts types. The wrapper signatures reference methods from recent JavaScript libs (findLast, Promise.try, the Set set-theory operations, Uint8Array.toBase64). Your tsconfig.json must include a lib version that knows about them:

{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2024", "DOM"],
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true
}
}
TypeScript fieldRecommendedMinimumWhy
TypeScript5.4+5.0Tuple/template-literal inference for prompts.
targetES2022ES2020Top-level await in your own files.
libES2024ES2022findLast, Set ops, Promise.try.

If your build target is older than ES2022, neuro-ts itself still works (every wrapper is async and the runtime feature-detects), but the TypeScript checker may flag method names it does not recognise.

<script src="https://unpkg.com/neuro-ts/dist/neuro-ts.iife.js"></script>
<script>
NeuroTS.configureClient({
tokenProvider: () => fetch('/api/neuro-token').then((r) => r.text()),
});
NeuroTS.neuro.array
.map({ array: ['a', 'b'], callbackfn: (s) => s, prompt: 'uppercase each' })
.then(console.log);
</script>
import { configureClient, neuro } from 'neuro-ts';
configureClient({ apiKey: process.env.OPENAI_API_KEY });
console.log(await neuro.math.random({}));

The same npm install also exposes two server-only subpaths for building a proxy or token-issuer endpoint. They are excluded from the browser bundle so the OpenAI SDK never reaches the client:

import { createNeuroProxy } from 'neuro-ts/proxy';
import { createTokenIssuer, tokenProviderFromUrl } from 'neuro-ts/issue-token';

See Custom proxy contract and Deploy the proxy for full setup.