nilai-ai-sdk-provider
v1.0.2
Published
Vercel AI SDK provider for Nillion's nilAI which runs AI models in a trusted execution environment (TEE)
Maintainers
Readme
nilai-ai-sdk-provider
A custom Vercel AI SDK provider for Nillion's nilAI - privacy-preserving AI that runs in a trusted execution environment (TEE).
Prerequisites
To use nilAI, you'll need:
- Nillion Wallet: https://docs.nillion.com/community/guides/nillion-wallet
- Testnet NIL tokens: https://docs.nillion.com/community/guides/testnet-faucet
- nilAI API Key: https://docs.nillion.com/build/network-api-access
Installation
npm install nilai-ai-sdk-provider ai dotenvQuick Start
- Create a
.envfile:
NILLION_NILAI_API_KEY="your-api-key-here"- Use the provider:
import { generateText } from 'ai';
import { nilai } from 'nilai-ai-sdk-provider';
import 'dotenv/config';
const result = await generateText({
model: nilai(),
prompt: 'Explain quantum computing in simple terms',
});
console.log(result.text);Examples
See /examples for complete examples:
Configuration
Provider Settings
const model = nilai({
temperature: 0.7, // 0-1, default 0.7
maxTokens: 1000, // default 1000
topP: 0.9, // 0-1, default 0.9
webSearch: true, // Enable web search
});Per-request Options
const result = await generateText({
model: nilai(),
prompt: 'Latest AI news',
providerOptions: {
nilai: { webSearch: true },
},
});Features
- Privacy-preserving: All inference runs in a TEE
- Streaming support: Real-time response streaming
- Web search: Automatic date context injection for temporal queries
- TypeScript native: Full type definitions included
- Error handling: Comprehensive error messages
Rate Limits
Testnet limits:
- 500 requests/day
- 100 requests/hour
- 10 requests/minute
- 100 web searches
API Reference
nilai(settings?)
Creates a language model instance.
createNilai(options)
Advanced configuration with custom base URL and headers.
See TypeScript definitions for complete API documentation.
Support
License
MIT - see LICENSE
