Documentation Index
Fetch the complete documentation index at: https://docs.legnext.ai/llms.txt
Use this file to discover all available pages before exploring further.
Get Your API Key
- Visit Legnext Dashboard
- Log in to your account
- Navigate to API Keys section
- Create a new API key
- Copy and save it securely
Using Your API Key
Method 1: Direct Initialization
const { Configuration, ImageApi } = require('@legnext-api/js-sdk');
const config = new Configuration({
basePath: 'https://api.legnext.ai'
});
const imageApi = new ImageApi(config);
const apiKey = 'your-api-key-here';
// Use apiKey as first parameter in method calls
TypeScript:
import { Configuration, ImageApi } from '@legnext-api/js-sdk';
const config = new Configuration({
basePath: 'https://api.legnext.ai'
});
const imageApi = new ImageApi(config);
const apiKey: string = 'your-api-key-here';
// Use apiKey as first parameter in method calls
Method 2: Environment Variable (Recommended)
Set the environment variable:
# macOS/Linux
export LEGNEXT_API_KEY="your-api-key-here"
# Windows CMD
set LEGNEXT_API_KEY=your-api-key-here
# Windows PowerShell
$env:LEGNEXT_API_KEY="your-api-key-here"
Then in your code:
const apiKey = process.env.LEGNEXT_API_KEY;
const imageApi = new ImageApi(apiClient);
// Use apiKey in method calls
Method 3: .env File (Node.js)
Create a .env file:
LEGNEXT_API_KEY=your-api-key-here
LEGNEXT_BASE_URL=https://api.legnext.ai
Install and use dotenv:
require('dotenv').config();
const { Configuration, ImageApi } = require('@legnext-api/js-sdk');
const config = new Configuration({
basePath: process.env.LEGNEXT_BASE_URL || 'https://api.legnext.ai'
});
const imageApi = new ImageApi(config);
const apiKey = process.env.LEGNEXT_API_KEY;
Method 4: ES Modules
import 'dotenv/config';
import { Configuration, ImageApi } from '@legnext-api/js-sdk';
const config = new Configuration({
basePath: process.env.LEGNEXT_BASE_URL || 'https://api.legnext.ai'
});
const imageApi = new ImageApi(config);
const apiKey = process.env.LEGNEXT_API_KEY;
Security Best Practices
⚠️ Never hardcode API keys in your code
✅ Always use environment variables
✅ Add .env to .gitignore
✅ Never expose API keys in client-side JavaScript
✅ Rotate keys regularly and revoke compromised ones
Next Steps