Documentation Index Fetch the complete documentation index at: https://docs.verlon.ai/llms.txt
Use this file to discover all available pages before exploring further.
The Verlon SDK provides a unified interface for AI capabilities across multiple providers. Use one SDK to access chat, image generation, embeddings, text-to-speech, video generation, and OCR.
Installation
npm install @verlon-ai/sdk
Quick Start
import { Verlon } from '@verlon-ai/sdk' ;
const verlon = new Verlon ({
apiKey: process . env . VERLON_API_KEY
});
const response = await verlon . chat ({
gateId: 'your-gate-id' ,
data: {
messages: [
{ role: 'user' , content: 'Hello!' }
]
}
});
console . log ( response . content );
Configuration
Initialize the Client
import { Verlon } from '@verlon-ai/sdk' ;
const verlon = new Verlon ({
apiKey: 'your-api-key' , // Required
baseUrl: 'https://custom.api' // Optional, defaults to https://api.verlon.ai
});
Never commit API keys to version control. Use environment variables.
Get Your API Key
Sign up at verlon.ai/signup
Get your API key from the Dashboard
Store it in an environment variable
VERLON_API_KEY = your-api-key-here
Available Methods
The SDK provides methods for different AI capabilities:
Chat Text generation with streaming, vision, and function calling
Images Generate images from text prompts
Video Create videos from text descriptions
Embeddings Generate vector embeddings for text
Audio Convert text to speech
OCR Extract text from images
Response Structure
All SDK methods return a VerlonResponse object:
interface VerlonResponse {
// Common fields
id : string ; // Request ID
model : string ; // Model used
cost : number ; // Request cost in USD
latency : number ; // Response time in ms
// Method-specific fields
content ?: string ; // Chat response text
data ?: any []; // Image/video/embedding data
url ?: string ; // Audio file URL
text ?: string ; // OCR extracted text
// Usage statistics
usage ?: {
promptTokens : number ;
completionTokens : number ;
totalTokens : number ;
};
}
Error Handling
Wrap SDK calls in try-catch blocks:
try {
const response = await verlon . chat ({
gateId: 'your-gate-id' ,
data: {
messages: [{ role: 'user' , content: 'Hello!' }]
}
});
console . log ( response . content );
} catch ( error ) {
console . error ( 'Error:' , error . message );
}
Common Error Messages
Error Cause Invalid tokenCheck your API key Gate not foundVerify gate ID is correct Rate limit exceededToo many requests, slow down Insufficient creditsAdd credits to your account
TypeScript Support
The SDK is fully typed:
import { Verlon , ChatRequest , VerlonResponse } from '@verlon-ai/sdk' ;
const verlon = new Verlon ({
apiKey: process . env . VERLON_API_KEY !
});
// TypeScript knows the structure
const response : VerlonResponse = await verlon . chat ({
gateId: 'your-gate-id' ,
data: {
messages: [
{ role: 'user' , content: 'Hello!' }
]
}
});
// Autocomplete and type safety
console . log ( response . content ); // TypeScript knows this exists
console . log ( response . cost ); // TypeScript knows this is a number
Environment Variables
Best practice for managing credentials:
// Good ✅
const verlon = new Verlon ({
apiKey: process . env . VERLON_API_KEY
});
// Bad ❌
const verlon = new Verlon ({
apiKey: 'lyr_hardcoded_key' // Never do this!
});
Next Steps
Explore specific capabilities:
Or learn about core concepts:
Gates & Routing How Verlon routes requests to models
Creating Gates Configure gates in the dashboard