> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nano-gpt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JavaScript SDK

> Use the official NanoGPT client, @nanogpt/sdk, from JavaScript

# JavaScript SDK

`@nanogpt/sdk` is NanoGPT's official client and works from plain JavaScript. It is ESM-only and needs Node.js 22 or later, or another runtime with Fetch and Web Streams.

```bash theme={null}
npm install @nanogpt/sdk
```

```javascript theme={null}
import { NanoGPT } from '@nanogpt/sdk';

const client = new NanoGPT({ apiKey: process.env.NANOGPT_API_KEY });

const completion = await client.chat.completions.create({
  model: 'openai/gpt-6.1-sol',
  messages: [{ role: 'user', content: 'Say hello in one sentence.' }],
});

console.log(completion.choices[0]?.message?.content);
```

Save this as a `.mjs` file, or set `"type": "module"` in your `package.json`.

See the [TypeScript SDK](https://docs.nano-gpt.com/api-reference/miscellaneous/typescript.md) page for the full list of methods, streaming and error handling.

## Other packages

`nanogptjs`, `nanogpt-client` and the npm package named `nanogpt` aren't published or reviewed by NanoGPT. They would receive your API key, so check them yourself before using them.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.