Skip to main content

Usage

Once you have nilAI API access, you can start using LLMs on nilAI with any OpenAI-compatible library.

Getting Started with Private LLMs

pnpm install @nillion/nilai-ts

You can either use:

  • API Key flow as the sole developer / organization or
  • Delegation Flow to provide permissions to another user / organization.

API Key Flow

  1. Use https://api.nilai.nillion.network/v1 as the BASE URL
  2. Check available models or query the /v1/models endpoint or
  3. Select an available model and use it with the /v1/chat/completions nilAI node endpoint

With OpenAI compatibility, you can use any OpenAI library. Here's an example for querying the gpt-oss-20b model:

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.

examples/1-delegation-token.ts
loading...