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 $ pnpm add neuro-ts $ yarn add neuro-ts $ bun add neuro-ts $ deno add npm:neuro-ts Peer requirements
Section titled “Peer requirements”| Runtime | Minimum |
|---|---|
| Node | 18.18 |
| Bun | 1.0 |
| Modern browsers | ES2022 |
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.
TypeScript configuration
Section titled “TypeScript configuration”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 field | Recommended | Minimum | Why |
|---|---|---|---|
| TypeScript | 5.4+ | 5.0 | Tuple/template-literal inference for prompts. |
target | ES2022 | ES2020 | Top-level await in your own files. |
lib | ES2024 | ES2022 | findLast, 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.
CDN (no build tool)
Section titled “CDN (no build tool)”<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>Verify your install
Section titled “Verify your install”import { configureClient, neuro } from 'neuro-ts';
configureClient({ apiKey: process.env.OPENAI_API_KEY });console.log(await neuro.math.random({}));Server-side subpaths
Section titled “Server-side subpaths”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.