JavaScript SDK
Use the official Lexa JavaScript SDK to integrate Lexa AI into your applications with a familiar OpenAI-style API.Install from NPM
Get the latest version:
npm install @robilabs/lexa@latestQuick Start
Installation
Basic Usage
Features
- OpenAI-style API - Familiar interface, easy migration
- Real Lexa Models - Access to lexa-mml, lexa-x1, lexa-rho
- TypeScript Support - Full type definitions included
- Streaming Support - Real-time text generation
- Multimodal Capabilities - Vision and text processing
- Simple Setup - Just install and start using
Available Models
The SDK provides access to the following Lexa models:lexa-mml
Multimodal model with vision capabilities (8192 context window)
lexa-x1
Fast, lightweight text-based model (4096 context window)
lexa-rho
Reasoning model with enhanced capabilities (16384 context window)
Usage Examples
Basic Chat Completion
Conversation with System Message
Streaming Response
List Available Models
API Reference
Constructor
apiKey(string): Your Lexa API keyconfig(object, optional): Configuration optionsbaseURL(string): Custom base URL (default: ‘https://www.lexa.chat/api’)
Chat Completion
messages(array): Array of message objectsmodel(string): Model to use (default: ‘lexa-mml’)temperature(number, optional): Controls randomness (0-2)max_tokens(number, optional): Maximum tokens to generatestream(boolean, optional): Enable streaming response
List Models
Migration from OpenAI
If you’re currently using OpenAI’s SDK, migrating to Lexa is straightforward:- Before (OpenAI)
- After (Lexa)
Installation Options
- npm
- yarn
- pnpm
Get Your API Key
1
Visit Lexa Chat
Go to https://www.lexa.chat
2
Sign up or log in
Create an account or sign in to your existing account
3
Navigate to Account settings
Click your avatar → Settings → Account tab
4
Generate API key
Find “API Keys” and click “Show” to view your key
5
Use in your application
Copy the key and use it in your Lexa SDK initialization
Links
NPM Package
View on npm registry
GitHub Repository
Source code and issues
Lexa Chat
Try Lexa online
Community
Join our community
Support
- Issues: GitHub Issues
- Email: lexa@robiai.com
- Community: Robi AI Community