### Install dependencies and run the app Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/llms/quickstart.mdx Installs project dependencies using pnpm and starts the development server. ```bash pnpm i pnpm run dev ``` -------------------------------- ### Project Setup Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/storage/quickstart.mdx Commands to clone the demo repository, install dependencies, and run the development server. ```bash git clone https://github.com/NillionNetwork/blind-module-examples cd blind-module-examples/nildb/secretvaults-ts/standard-collection/nextjs-app-metamask-full pnpm install pnpm run dev ``` -------------------------------- ### Install nilai-py with uv Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/llms/sdks/quickstart.mdx Installs the nilai-py Python package using uv. ```bash uv pip install nilai-py ``` -------------------------------- ### Clone the examples repo and move into the Next.js example Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/llms/quickstart.mdx Clones the Nillion blind module examples repository and navigates into the secretllm_nextjs directory. ```bash gh repo clone NillionNetwork/blind-module-examples cd blind-module-examples/nilai/secretllm_nextjs ``` -------------------------------- ### Install @nillion/nilai-ts Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/llms/sdks/quickstart.mdx Installs the @nillion/nilai-ts TypeScript package using pnpm. ```bash pnpm install @nillion/nilai-ts ``` -------------------------------- ### Install nilai-py with pip Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/llms/sdks/quickstart.mdx Installs the nilai-py Python package using pip. ```bash pip install nilai-py ``` -------------------------------- ### Delegated Signing Flow - Python Example Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/llms/sdks/quickstart.mdx Example code for the delegated signing flow in Python. ```python https://github.com/NillionNetwork/nilai-py/blob/main/examples/1-delegation_token_mode.py ``` -------------------------------- ### Create your .env file Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/llms/quickstart.mdx Copies the example environment file to create a new .env file for configuration. ```bash cp .env.example .env ``` -------------------------------- ### Direct Signing Flow - Python Example Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/llms/sdks/quickstart.mdx Example code for querying a model using the Direct Signing flow in Python. ```python https://github.com/NillionNetwork/nilai-py/blob/main/examples/0-api_key_mode.py ``` -------------------------------- ### Direct Signing Flow - TypeScript Example Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/llms/sdks/quickstart.mdx Example code for querying a model using the Direct Signing flow in TypeScript. ```typescript https://github.com/NillionNetwork/nilai-ts/blob/main/examples/0-api-key.ts ``` -------------------------------- ### Delegated Signing Flow - TypeScript Example Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/llms/sdks/quickstart.mdx Example code for the delegated signing flow in TypeScript. ```typescript https://github.com/NillionNetwork/nilai-ts/blob/main/examples/1-delegation-token.ts ``` -------------------------------- ### Delegated Signing Flow - Next.js Example Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/llms/sdks/quickstart.mdx Example code for the delegated signing flow in Next.js, demonstrating server and client interactions. ```typescript https://github.com/NillionNetwork/blind-module-examples/blob/main/nilai/secretllm_nextjs_sdk/app/api/chat-delegation/route.ts ``` -------------------------------- ### Query Operations on Encrypted Data Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/storage/quickstart.mdx Example of creating and running queries on encrypted data, including defining variables and a pipeline for matching and counting. ```javascript // Create and run queries on encrypted data const query = { _id: randomUUID(), name: 'Find Users by Name', collection: collectionId, variables: { searchName: { description: 'Name to search for', path: '$.pipeline[0].$match.name', }, }, pipeline: [{ $match: { name: '' } }, { $count: 'total' }], }; await builder.createQuery(query); ``` -------------------------------- ### Install Docker on Linux Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blacklight/run-node/setup.mdx Commands to install Docker on Linux by downloading and running the official installation script. ```bash curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh ``` -------------------------------- ### Volume Mount Example Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/compute/limitations.md Illustrates the correct syntax for volume mounts, which must start with $FILES or ${FILES}. ```bash Example: $FILES/data:/app/data ✓ Example: /home/user/data:/app/data ✗ ``` -------------------------------- ### Install Dependencies Source: https://github.com/nillionnetwork/nillion-docs/blob/main/README.md Installs the necessary dependencies for running the Nillion documentation locally. ```bash $ yarn install ``` -------------------------------- ### Install Docker on macOS Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blacklight/run-node/setup.mdx Command to install Docker on macOS using Homebrew. ```bash brew install --cask docker ``` -------------------------------- ### Install Dependencies Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/storage/metamask-guide.md Install the necessary dependencies for the Nillion and SecretVaults SDKs, along with viem and react-query. ```bash cd nillion-mm-demo pnpm install pnpm dev ``` ```bash npx create-next-app@latest my-app --yes npm install @nillion/nuc @nillion/secretvaults viem @tanstack/react-query ``` -------------------------------- ### Start Local Development Server Source: https://github.com/nillionnetwork/nillion-docs/blob/main/README.md Starts a local development server for the Nillion documentation. Changes are reflected live without server restart. ```bash $ yarn start ``` -------------------------------- ### Authentication Example Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/compute/api-reference.md Example of how to authenticate API requests using the 'x-api-key' header. ```bash curl -X POST https://api.nilcc.nillion.network/api/v1/workloads/create \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" ``` -------------------------------- ### Create React App and Install Dependencies Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/storage/platform-react.md Creates a new React app, installs Nillion libraries, and browser polyfill packages. ```bash npx create-react-app my-nillion-app --template typescript cd my-nillion-app npm install @nillion/nuc @nillion/secretvaults npm install --save-dev react-app-rewired assert buffer crypto-browserify os-browserify path-browserify process stream-browserify url util ``` -------------------------------- ### Start Blacklight Node (Mainnet) Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blacklight/run-node/setup.mdx Starts the Blacklight node after initialization and staking. This command is for the mainnet. ```bash docker run -it --rm -v ./blacklight_node:/app/ -v ./blacklight_node:/tmp/blacklight-cache ghcr.io/nillionnetwork/blacklight-node/blacklight_node:0.10.0 --rpc-url https://rpc.nillion.network --manager-contract-address 0x0Ee49a8f50293Fa5d05Ba6d1FC136e7F79b2eA4f --staking-contract-address 0x89c1312Cedb0B0F67e4913D2076bd4a860652B69 --token-contract-address 0x32DEAe728473cb948B4D8661ac0f2755133D4173 ``` -------------------------------- ### Python Web Search Example Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/llms/sdks/web_search.mdx Example demonstrating how to enable and use web search in Python. ```python https://github.com/NillionNetwork/nilai-py/blob/main/examples/7-web-search.py ``` -------------------------------- ### Create Next.js App & Install Dependencies Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/storage/platform-nextjs.md Creates a new Next.js app and installs the Nillion libraries. ```bash npx create-next-app@latest my-nillion-app --typescript cd my-nillion-app ``` -------------------------------- ### Create Project & Install Dependencies Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/storage/platform-nodejs.md Commands to create a new Node.js project and install Nillion libraries and TypeScript tooling. ```bash mkdir my-nillion-app cd my-nillion-app npm init -y ``` ```bash npm install @nillion/nuc @nillion/secretvaults npm install -D typescript @types/node tsx dotenv ``` -------------------------------- ### Example Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/api/nilai/health-check-v-1-health-get.api.mdx Retrieve system health status ```python # Retrieve system health status health = await health_check() # Expect: HealthCheckResponse(status='ok', uptime=3600) ``` -------------------------------- ### Add your nilAI API key Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/llms/quickstart.mdx Sets the NILLION_API_KEY environment variable with your actual API key. ```bash NILLION_API_KEY=YOUR_API_KEY_HERE ``` -------------------------------- ### CRUD Operations with %allot Marker Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/storage/quickstart.mdx Demonstrates Create, Read, Update, and Delete operations, highlighting how content is wrapped in { "%allot": value } for encryption and distribution across nilDB nodes. ```typescript https://github.com/NillionNetwork/blind-module-examples/blob/main/nildb/secretvaults-ts/standard-collection/nextjs-app-metamask-full/src/hooks/useNotes.ts ``` -------------------------------- ### Verify Security (Check Attestation) Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/compute/quickstart.md Prove your workload runs in a secure TEE by checking the attestation report. ```bash curl https://[your-running-workload]/nilcc/api/v2/report ``` -------------------------------- ### Client Query Example Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/llms/nilRAG.md Example of a client query asking about a specific person. ```text Who is Danielle Miller? ``` -------------------------------- ### Update data example Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/api/nildb/update-data.api.mdx Example of how to update a document using the $set operator. ```json { "schema": "c48dcfb6-dd97-4ee6-b227-1f6c334685f8", "filter": { "_id": "f7bca333-b0b9-472a-9649-e17d23f7ccc0" }, "update": { "$set": { "steps": 100 } } } ``` -------------------------------- ### Docker Compose File Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/compute/quickstart.md Create a simple API service using Docker Compose. ```yaml services: web: image: caddy:2 command: | caddy respond --listen :8080 --body '{"hello":"world"}' --header "Content-Type: application/json" ``` -------------------------------- ### Access Your Secure API Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/compute/quickstart.md Access your deployed workload at its unique domain. ```bash # Your workload will be available at a domain like: curl https://[your-running-workload] ``` -------------------------------- ### Example Request Body Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/api/nilai/chat-completion-v-1-chat-completions-post.api.mdx An example of a request body for the Chat Completions API. ```json { "model": "google/gemma-4-26B-A4B-it", "messages": [ { "role": "system", "content": "You are a helpful assistant" }, { "role": "user", "content": "What is your name?" } ], "temperature": 0.2, "top_p": 0.95, "max_tokens": 2048, "stream": false, "nilrag": {} } ``` -------------------------------- ### Install Nillion Dependencies Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/storage/platform-nextjs.md Installs Nillion dependencies for the Next.js app. ```bash npm install @nillion/nuc @nillion/secretvaults ``` -------------------------------- ### Example Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/api/nilai/get-models-v-1-models-get.api.mdx Retrieves list of available models ```python # Retrieves list of available models models = await get_models(user) ``` -------------------------------- ### Run Your App Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/storage/platform-react.md This command starts the development server for a Create React App project, allowing you to see your Nillion-integrated React application in action. ```bash npm start ``` -------------------------------- ### Create Workload with API Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/compute/quickstart.md Create a new workload programmatically with the nilCC API. Update the command below with your nilCC API key, chosen resource tier, and the latest artifacts version. ```bash curl -X POST https://api.nilcc.nillion.network/api/v1/workloads/create \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ \ "name": "hello-world-api", \ "dockerCompose": "services:\n web:\n image: caddy:2\n command: |\n caddy respond --listen :8080 --body '\''{\"hello\":\"world\"}'\'' --header \"Content-Type: application/json\"", \ "serviceToExpose": "web", \ "servicePortToExpose": 8080, \ "cpus": YOUR_CPUS, \ "memory": YOUR_MEMORY, \ "disk": YOUR_DISK, \ "gpus": YOUR_GPUS, \ "artifactsVersion": LATEST_ARTIFACTS_VERSION \ }' ``` -------------------------------- ### Employees Example Data Source: https://github.com/nillionnetwork/nillion-docs/blob/main/docs/blind-computer/build/llms/nilRAG.md An example of employee data that a data owner might upload to nilDB. ```text Kyle Moore works at Jackson, Gray and Lewis as a Economist. Kyle Moore was born on 1915-09-27 and lives at 6206 Caroline Point, Bishopland, MI 34522. Charles Anderson works at Evans, Parker and Ramirez as a Surveyor, insurance. Charles Anderson was born on 2016-12-13 and lives at 0527 William Walk Suite 976, Lake Jason, MS 97840. Danielle Miller works at Bailey and Sons as a Engineer, mining. Danielle Miller was born on 2007-10-22 and lives at 61586 Michael Greens, New Holly, CO 29872. ... ```