Usage
Once you have nilAI API access, you can start using LLMs on nilAI with any OpenAI-compatible library.
Getting Started with Private LLMs
- Python
- TypeScript
- pip
- uv
pip install nilai-py
uv pip install nilai-py
pnpm install @nillion/nilai-ts
You can either use:
API Keyflow as the sole developer / organization orDelegation Flowto provide permissions to another user / organization.
API Key Flow
- Use
https://api.nilai.nillion.network/v1as the BASE URL - Check available models or query the
/v1/modelsendpoint or - Select an available model and use it with the
/v1/chat/completionsnilAI node endpoint
With OpenAI compatibility, you can use any OpenAI library. Here's an example for querying the gpt-oss-20b model:
- Python
- Typescript
examples/0-api_key_mode.py
loading...
examples/0-api-key.ts
loading...
Delegation flow
To use the delegation flow, you need to create a delegation token server.
The server then creates the delegation tokens and managing their expiration and usage. Then the delegation token allows you to make requests to the nilAI API.
- Python
- Typescript
examples/1-delegation_token_mode.py
loading...
examples/1-delegation-token.ts
loading...