JavaScript API¶
Beside the Python and C++ API, XGrammar also provides JavaScript/TypeScript API.
The JS SDK uses emscripten to compile the C++ code into WebAssembly. It is designed to be used for LLMs that run in the browser, such as WebLLM.
To use this SDK, run:
npm install @mlc-ai/web-xgrammar
For more information, see the code.