Official JavaScript and TypeScript SDK for accessing SVECTOR APIs.
SVECTOR develops high-performance AI models and automation solutions, specializing in artificial intelligence, mathematical computing, and computational research. This SDK provides programmatic access to SVECTOR's API services through type-safe JavaScript/TypeScript interfaces, completion endpoints, document processing capabilities, and additional AI model integrations.
Multi-Platform Support: This repository contains both the npm package (svector-sdk) and the JSR package (@svector/svector) for seamless integration across Node.js, Deno, Bun, and browser environments.
This repository contains both package distributions:
svector-node/
├── src/ # npm package source (Node.js/TypeScript)
│ ├── api/ # API implementations │ ├── client.ts # Main client
│ ├── types.ts # TypeScript definitions
│ └── index.ts # npm package entry
├── jsr/ # JSR package source (Deno/JSR)
│ ├── api/ # Deno-compatible API implementations
│ ├── client.ts # Deno-compatible client
│ ├── mod.ts # JSR package entry │ └── deno.json # Deno configuration
├── examples/ # Usage examples
└── package.json # npm package config
Package Locations:
- Website: https://www.svector.co.in
- Documentation: API Reference
- Issues: GitHub Issues
- Support: support@svector.co.in
- npm Package: svector-sdk
- JSR Package: @svector/svector
- Deno Land: deno.land/@svector/svector- Full-featured package for Node.js/Bun
- JSR:
@svector/svector- Deno-optimized package from/jsrfolder)
npm install svector-sdkimport{SVECTOR}from'svector-sdk';constclient=newSVECTOR({apiKey: process.env.SVECTOR_API_KEY,});constresult=awaitclient.conversations.create({model: 'spec-3-turbo',instructions: 'You are a helpful AI assistant that explains complex topics clearly.',input: 'What is artificial intelligence?',});console.log(result.output);deno add jsr:@svector/svectorimport{SVECTOR}from"jsr:@svector/svector";constclient=newSVECTOR({apiKey: Deno.env.get("SVECTOR_API_KEY"),});constresult=awaitclient.conversations.create({model: 'spec-3-turbo',instructions: 'You are a helpful AI assistant that explains complex topics clearly.',input: 'What is artificial intelligence?',});console.log(result.output);- Installation
- Authentication
- Repository Structure
- Core Features
- Conversations API (Recommended)
- Chat Completions API (Advanced)
- Streaming Responses
- File Management & Document Processing
- Vision & Image Analysis
- Models
- Error Handling
- Advanced Configuration
- Environment Support
- Complete Examples
- Best Practices
- Contributing
npm install svector-sdk
# or
yarn add svector-sdk# Using JSR (recommended for Deno)
deno add jsr:@svector/svector
# Or using npm package in Deno
deno add npm:svector-sdkimport{SVECTOR}from'jsr:@svector/svector';import{SVECTOR}from'https://esm.sh/svector-sdk';Get your API key from the SVECTOR Platform and set it as an environment variable:
export SVECTOR_API_KEY="your-api-key-here"Or pass it directly to the client:
constclient=newSVECTOR({apiKey: 'your-api-key-here',});- Conversations API - Simple instructions + input interface
- Advanced Chat Completions - Full control with role-based messages
- Real-time Streaming - Server-sent events for live responses
- File Processing - Upload and process documents (PDF, DOCX, TXT, etc.)
- Knowledge Collections - Organize files for enhanced RAG
- TypeScript Native - Full type safety and IntelliSense
- Multi-environment - Node.js, Browser, Deno, Bun, Cloudflare Workers
- Robust Error Handling - Comprehensive error types and retry logic
The Conversations API provides a sophisticated, user-friendly interface. Just provide instructions and input - the SDK handles all the complex role management internally!
import{SVECTOR}from'svector-sdk';constclient=newSVECTOR({apiKey: process.env.SVECTOR_API_KEY,});constresult=awaitclient.conversations.create({model: 'spec-3-turbo',instructions: 'You are a helpful assistant that explains things clearly.',input: 'What is machine learning?',temperature: 0.7,max_tokens: 200,});console.log(result.output);// "Machine learning is a subset of artificial intelligence..."constresult=awaitclient.conversations.create({model: 'spec-3-turbo',instructions: 'You are a programming tutor that helps students learn coding.',input: 'Can you show me an example?',context: ['How do I create a function in Python?','You can create a function using the def keyword followed by the function name and parameters...'],temperature: 0.5,});conststream=awaitclient.conversations.createStream({model: 'spec-3-turbo',instructions: 'You are a creative storyteller.',input: 'Tell me a short story about robots and humans.',stream: true,});console.log('Story: ');forawait(consteventofstream){if(!event.done){process.stdout.write(event.content);}}importfsfrom'node:fs';import{SVECTOR}from'svector-sdk';constclient=newSVECTOR({apiKey: process.env.SVECTOR_API_KEY,});asyncfunctionanalyzeDocument(filePath,question="Analyze this document and provide key findings."){constfileResponse=awaitclient.files.create(fs.readFileSync(filePath),'default',filePath.split('/').pop());constresult=awaitclient.conversations.create({model: 'spec-3-turbo',instructions: 'You are a document analyst. Provide clear, concise analysis.',input: `${question}\n\nDocument content:\n${fileResponse.data.content}`,temperature: 0.3,});console.log(result.output);returnresult.output;}awaitanalyzeDocument('document.pdf');For full control over the conversation structure, use the Chat Completions API with role-based messages:
constcompletion=awaitclient.chat.create({model: 'spec-3-turbo',messages: [{role: 'system',content: 'You are a helpful assistant.'},{role: 'user',content: 'Hello, how are you?'}],max_tokens: 150,temperature: 0.7,});console.log(completion.choices[0].message.content);constconversation=[{role: 'system',content: 'You are a helpful programming assistant.'},{role: 'user',content: 'How do I reverse a string in Python?'},{role: 'assistant',content: 'You can reverse a string using slicing: string[::-1]'},{role: 'user',content: 'Can you show me other methods?'}];constresponse=awaitclient.chat.create({model: 'spec-3-turbo',messages: conversation,temperature: 0.5,});constresponse=awaitclient.chat.create({model: 'spec-3-turbo',messages: [{role: 'developer',content: 'You are an expert code reviewer. Provide detailed feedback.'},{role: 'user',content: 'Please review this Python code: def add(a, b): return a + b'}],});Both Conversations and Chat APIs support real-time streaming:
conststream=awaitclient.conversations.createStream({model: 'spec-3-turbo',instructions: 'You are a creative writer.',input: 'Write a poem about technology.',stream: true,});forawait(consteventofstream){if(!event.done){process.stdout.write(event.content);}else{console.log('\n✓ Stream completed');}}conststream=awaitclient.chat.createStream({model: 'spec-3-turbo',messages: [{role: 'system',content: 'You are a helpful assistant.'},{role: 'user',content: 'Explain quantum computing'}],stream: true,});forawait(consteventofstream){if(event.choices?.[0]?.delta?.content){process.stdout.write(event.choices[0].delta.content);}}Upload and process various file formats for enhanced AI capabilities:
importfsfrom'node:fs';constfileResponse=awaitclient.files.create(fs.readFileSync('document.pdf'),'default','document.pdf');console.log(`File uploaded: ${fileResponse.id}`);constbuffer=fs.readFileSync('document.pdf');constfileResponse=awaitclient.files.create(buffer,'default','document.pdf');constcontent=`# Research NotesThis document contains important findings...`;constfileResponse=awaitclient.files.create(content,'default','notes.md');constfileInput=document.getElementById('fileInput')asHTMLInputElement;constfile=fileInput.files[0];constclient=newSVECTOR({apiKey: process.env.SVECTOR_API_KEY,dangerouslyAllowBrowser: true,});constfileResponse=awaitclient.files.create(file,'default');import{toFile}from'svector-sdk';// Convert buffer to fileconstbuffer=Buffer.from('Hello world');constfile=awaittoFile(buffer,'hello.txt');constresponse=awaitclient.files.create(file,'default');// Convert string to fileconststringFile=awaittoFile('Content here','content.txt',{type: 'text/plain'});constdoc1=awaitclient.files.create(fs.readFileSync('manual.pdf'),'default','manual.pdf');constdoc2=awaitclient.files.create(fs.readFileSync('faq.docx'),'default','faq.docx');constanswer=awaitclient.conversations.create({model: 'spec-3-turbo',instructions: 'You are a helpful assistant that answers questions based on provided documents.',input: `What are the key features mentioned in the manual?\n\nDocument 1: ${doc1.data.content}\nDocument 2: ${doc2.data.content}`,});Organize multiple files into collections for better performance and context management:
// Add files to a knowledge collectionconstresult1=awaitclient.knowledge.addFile('collection-123','file-456');constresult2=awaitclient.knowledge.addFile('collection-123','file-789');// Use the entire collection in conversationsconstresponse=awaitclient.conversations.create({model: 'spec-3-turbo',instructions: 'You are a research assistant with access to our knowledge base.',input: 'Summarize all the information about our products.',files: [{type: 'collection',id: 'collection-123'}],});SVECTOR provides powerful, proprietary vision capabilities for analyzing, understanding, and processing images. Our Vision API supports multiple input methods and provides specialized functions for different use cases, all optimized for SVECTOR's advanced AI models.
- Flexible Input Methods: URL, base64, and file ID support
- Specialized Functions: OCR, accessibility, object detection, and comparison
- Production Ready: Built-in rate limiting, error handling, and batch processing
- Multi-Platform: Works across Node.js, Deno, browsers, and edge environments
- PNG (.png)
- JPEG (.jpeg, .jpg)
- WEBP (.webp)
- GIF (.gif) - Non-animated only
The Vision API supports three ways to provide images:
- Image URL - Direct links to images
- Base64 encoding - For local files and programmatic use
- File ID - Using SVECTOR's file upload system
import{SVECTOR}from'svector-sdk';constclient=newSVECTOR({apiKey: process.env.SVECTOR_API_KEY,});constresult=awaitclient.vision.analyzeFromUrl('https://example.com/nature-scene.jpg','What do you see in this image? Describe the scene in detail.',{model: 'spec-3-turbo',max_tokens: 500,detail: 'high'// 'low', 'high', or 'auto'});console.log(result.analysis);// "This image shows a beautiful nature scene with mountains in the background..."importfsfrom'fs';// Method 1: Using base64 encodingconstimageBuffer=fs.readFileSync('./image.jpg');constbase64Image=imageBuffer.toString('base64');constresult=awaitclient.vision.analyzeFromBase64(base64Image,'Identify all objects and people in this image.',{model: 'spec-3-turbo',max_tokens: 1000,temperature: 0.3,detail: 'high'});console.log(result.analysis);// First upload the fileconstfileResponse=awaitclient.files.create(fs.readFileSync('./chart.png'),'default','chart.png');// Then analyze using file IDconstresult=awaitclient.vision.analyzeFromFileId(fileResponse.file_id,'Analyze this chart. What insights can you extract?',{model: 'spec-3-turbo',max_tokens: 800});console.log(result.analysis);constresult=awaitclient.vision.extractText({image_url: 'https://example.com/document-image.png',model: 'spec-3-turbo',max_tokens: 1000});console.log('Extracted text:',result.analysis);constresult=awaitclient.vision.describeForAccessibility({image_url: 'https://example.com/complex-chart.png',model: 'spec-3-turbo'});console.log('Alt text:',result.analysis);// Provides detailed description suitable for screen readersconstresult=awaitclient.vision.detectObjects({image_url: 'https://example.com/street-scene.jpg'},['cars','people','buildings','traffic signs']// Specific objects to detect);console.log('Detected objects:',result.analysis);constresult=awaitclient.vision.compareImages([{url: 'https://example.com/before.jpg'},{url: 'https://example.com/after.jpg'}],'Compare these before and after images. What changes do you notice?',{model: 'spec-3-turbo',max_tokens: 800});console.log('Comparison:',result.analysis);Integrate vision seamlessly with the Conversations API for context-aware image analysis:
constresult=awaitclient.conversations.create({model: 'spec-3-turbo',instructions: 'You are an expert image analyst and architectural historian.',input: [{type: 'text',text: 'What architectural style is shown in this building? Provide historical context.'},{type: 'image_url',image_url: {url: 'https://example.com/historic-building.jpg',detail: 'high'}}],max_tokens: 500});console.log(result.output);For more control over the conversation structure:
constcompletion=awaitclient.chat.create({model: 'spec-3-turbo',messages: [{role: 'system',content: 'You are a medical imaging specialist. Analyze images with clinical precision.'},{role: 'user',content: [{type: 'text',text: 'What do you observe in this medical scan?'},{type: 'image_url',image_url: {url: 'data:image/jpeg;base64,'+base64MedicalImage,detail: 'high'}}]}],max_tokens: 1000});For browser environments with file uploads:
constclient=newSVECTOR({apiKey: process.env.SVECTOR_API_KEY,dangerouslyAllowBrowser: true,});// Handle file inputconstfileInput=document.getElementById('imageInput')asHTMLInputElement;constfile=fileInput.files[0];if(file){// Convert to base64constreader=newFileReader();reader.onload=async(e)=>{constbase64=e.target.resultasstring;constresult=awaitclient.vision.analyzeFromBase64(base64,'Describe this image uploaded by the user.');console.log(result.analysis);};reader.readAsDataURL(file);}Process multiple images efficiently:
constimageUrls=['https://example.com/product1.jpg','https://example.com/product2.jpg','https://example.com/product3.jpg'];constanalyses=[];for(const[index,url]ofimageUrls.entries()){console.log(`Analyzing image ${index+1}/${imageUrls.length}...`);constresult=awaitclient.vision.analyzeFromUrl(url,'Describe this product and its key features.',{model: 'spec-3-turbo',max_tokens: 300});analyses.push({image: url,analysis: result.analysis,tokens: result.usage?.total_tokens});// Rate limiting courtesyawaitnewPromise(resolve=>setTimeout(resolve,1000));}console.log('Batch analysis complete:',analyses);Stream vision analysis for real-time applications:
conststream=awaitclient.conversations.createStream({model: 'spec-3-turbo',instructions: 'You are a technical image analyst. Provide detailed analysis.',input: [{type: 'text',text: 'Provide a comprehensive technical analysis of this image.'},{type: 'image_url',image_url: {url: 'https://example.com/technical-diagram.jpg',detail: 'high'}}],stream: true,max_tokens: 1000});console.log('Streaming analysis:');forawait(constchunkofstream){if(!chunk.done){process.stdout.write(chunk.content);}}| Parameter | Type | Description | Default |
|---|---|---|---|
image_url | string | Direct URL to image | - |
image_base64 | string | Base64 encoded image data | - |
file_id | string | Uploaded file ID | - |
prompt | string | Analysis instructions | Auto-generated |
model | string | Model to use | 'spec-3-turbo' |
max_tokens | number | Maximum response tokens | 1000 |
temperature | number | Response creativity (0-1) | 0.7 |
detail | string | Image analysis detail level | 'auto' |
low- Faster processing, basic analysishigh- Detailed analysis, slower processingauto- Automatically choose based on image
import{APIError,ValidationError}from'svector-sdk';try{constresult=awaitclient.vision.analyzeFromUrl('https://example.com/image.jpg','Analyze this image');console.log(result.analysis);}catch(error){if(errorinstanceofValidationError){console.error('Invalid image or parameters:',error.message);}elseif(errorinstanceofAPIError){console.error('API error:',error.message);}else{console.error('Unexpected error:',error);}}- Choose the right detail level: Use
highfor complex images requiring detailed analysis - Optimize image size: Smaller images process faster while maintaining quality
- Use specific prompts: Better prompts lead to more relevant analysis
- Handle rate limits: Add delays between batch requests
- Validate images: Ensure images meet format and content requirements
import{SVECTOR}from'svector-sdk';importfsfrom'fs';classVisionAnalyzer{privateclient: SVECTOR;constructor(apiKey: string){this.client=newSVECTOR({ apiKey });}asyncanalyzeImage(imagePath: string,prompt?: string): Promise<string>{try{// Method 1: Upload file and analyze by IDconstfileResponse=awaitthis.client.files.create(fs.readFileSync(imagePath),'default',imagePath.split('/').pop());constresult=awaitthis.client.vision.analyzeFromFileId(fileResponse.file_id,prompt||'Provide a comprehensive analysis of this image.',{model: 'spec-3-turbo',max_tokens: 800,detail: 'high'});returnresult.analysis;}catch(error){console.error('Vision analysis failed:',error);throwerror;}}asyncextractText(imagePath: string): Promise<string>{constimageBuffer=fs.readFileSync(imagePath);constbase64Image=imageBuffer.toString('base64');constresult=awaitthis.client.vision.extractText({image_base64: base64Image,model: 'spec-3-turbo'});returnresult.analysis;}asynccompareImages(image1Path: string,image2Path: string): Promise<string>{constimage1=fs.readFileSync(image1Path).toString('base64');constimage2=fs.readFileSync(image2Path).toString('base64');constresult=awaitthis.client.vision.compareImages([{base64: image1},{base64: image2}],'Compare these two images and describe the differences.');returnresult.analysis;}}// Usageconstanalyzer=newVisionAnalyzer(process.env.SVECTOR_API_KEY);constanalysis=awaitanalyzer.analyzeImage('./photo.jpg');console.log('📸 Analysis:',analysis);constextractedText=awaitanalyzer.extractText('./document.png');console.log('📄 Extracted text:',extractedText);constcomparison=awaitanalyzer.compareImages('./before.jpg','./after.jpg');console.log('🔄 Comparison:',comparison);For more advanced vision capabilities, check out the comprehensive examples in examples/advanced-vision.ts:
npm run examples:visionSVECTOR provides several cutting-edge foundational AI models:
// List all available modelsconstmodels=awaitclient.models.list();console.log(models.models);SVECTOR's Foundational Models:
spec-3-turbo- Fast, efficient model for most use casesspec-3- Standard model with balanced performancetheta-35-mini- Lightweight model for simple taskstheta-35- Advanced model for complex reasoning
// For quick responses and general tasksconstquickResponse=awaitclient.conversations.create({model: 'spec-3-turbo',instructions: 'You are a helpful assistant.',input: 'What time is it?',});// For complex reasoning and analysisconstcomplexAnalysis=awaitclient.conversations.create({model: 'theta-35',instructions: 'You are an expert data analyst.',input: 'Analyze the trends in this quarterly report.',files: [{type: 'file',id: 'report-file-id'}],});// For lightweight tasksconstsimpleTask=awaitclient.conversations.create({model: 'theta-35-mini',instructions: 'You help with simple questions.',input: 'What is 2 + 2?',});The SDK provides comprehensive error handling with specific error types:
import{SVECTOR,AuthenticationError,RateLimitError,NotFoundError,APIError}from'svector-sdk';constclient=newSVECTOR();try{constresponse=awaitclient.conversations.create({model: 'spec-3-turbo',instructions: 'You are a helpful assistant.',input: 'Hello world',});console.log(response.output);}catch(error){if(errorinstanceofAuthenticationError){console.error('Invalid API key:',error.message);}elseif(errorinstanceofRateLimitError){console.error('Rate limit exceeded:',error.message);}elseif(errorinstanceofNotFoundError){console.error('Resource not found:',error.message);}elseif(errorinstanceofAPIError){console.error(`API error: ${error.message} (Status: ${error.status})`);console.error(`Request ID: ${error.request_id}`);}else{console.error('Unexpected error:',error);}}AuthenticationError- Invalid API key or authentication issuesPermissionDeniedError- Insufficient permissions for the resourceNotFoundError- Requested resource not foundRateLimitError- API rate limit exceededUnprocessableEntityError- Invalid request data or parametersInternalServerError- Server-side errorsAPIConnectionError- Network connection issuesAPIConnectionTimeoutError- Request timeout
constclient=newSVECTOR({apiKey: process.env.SVECTOR_API_KEY,baseURL: 'https://api.svector.co.in',maxRetries: 3,timeout: 30000,dangerouslyAllowBrowser: false,fetch: customFetch,});constresponse=awaitclient.conversations.create({model: 'spec-3-turbo',instructions: 'You are a helpful assistant.',input: 'Hello',},{timeout: 60000,maxRetries: 1,headers: {'X-Custom-Header': 'value','X-Request-Source': 'my-app'}});// Get both response data and raw HTTP responseconst{ data, response }=awaitclient.conversations.createWithResponse({model: 'spec-3-turbo',instructions: 'You are a helpful assistant.',input: 'Hello',});console.log('Status:',response.status);console.log('Headers:',Object.fromEntries(response.headers.entries()));console.log('Response:',data.output);console.log('Request ID:',data._request_id);The SVECTOR SDK works across multiple JavaScript environments:
import{SVECTOR}from'svector-sdk';constclient=newSVECTOR({apiKey: process.env.SVECTOR_API_KEY,});import{SVECTOR}from'svector-sdk';constclient=newSVECTOR({apiKey: process.env.SVECTOR_API_KEY,dangerouslyAllowBrowser: true,});import{SVECTOR}from'jsr:@svector/svector';// orimport{SVECTOR}from'npm:svector-sdk';constclient=newSVECTOR({apiKey: Deno.env.get('SVECTOR_API_KEY'),});import{SVECTOR}from'svector-sdk';constclient=newSVECTOR({apiKey: process.env.SVECTOR_API_KEY,});import{SVECTOR}from'svector-sdk';exportdefault{asyncfetch(request,env){constclient=newSVECTOR({apiKey: env.SVECTOR_API_KEY,});constresult=awaitclient.conversations.create({model: 'spec-3-turbo',instructions: 'You are a helpful assistant.',input: 'Hello from Cloudflare Workers!',});returnnewResponse(result.output);}};import{SVECTOR}from'svector-sdk';classIntelligentChat{privateclient: SVECTOR;privateconversationHistory: string[]=[];constructor(apiKey: string){this.client=newSVECTOR({ apiKey });}asyncchat(userMessage: string,systemInstructions?: string): Promise<string>{// Add user message to historythis.conversationHistory.push(userMessage);constresult=awaitthis.client.conversations.create({model: 'spec-3-turbo',instructions: systemInstructions||'You are a helpful and friendly AI assistant.',input: userMessage,context: this.conversationHistory.slice(-10),// Keep last 10 messagestemperature: 0.7,});// Add AI response to historythis.conversationHistory.push(result.output);returnresult.output;}asyncstreamChat(userMessage: string): Promise<void>{console.log('Assistant: ');conststream=awaitthis.client.conversations.createStream({model: 'spec-3-turbo',instructions: 'You are a helpful AI assistant. Be conversational and engaging.',input: userMessage,context: this.conversationHistory.slice(-6),stream: true,});letfullResponse='';forawait(consteventofstream){if(!event.done){process.stdout.write(event.content);fullResponse+=event.content;}}console.log('\n');this.conversationHistory.push(userMessage,fullResponse);}clearHistory(): void{this.conversationHistory=[];}}// Usageconstchat=newIntelligentChat(process.env.SVECTOR_API_KEY);// Regular chatconsole.log(awaitchat.chat('Hello! How are you today?'));// Streaming chatawaitchat.streamChat('Tell me an interesting fact about space.');// Specialized chatconsole.log(awaitchat.chat('Explain quantum computing','You are a physics professor who explains complex topics in simple terms.'));import{SVECTOR}from'svector-sdk';importfsfrom'fs';classDocumentAnalyzer{privateclient: SVECTOR;privateuploadedFiles: string[]=[];constructor(){this.client=newSVECTOR();}asyncaddDocument(filePath: string): Promise<string>{try{constfileResponse=awaitthis.client.files.create(fs.createReadStream(filePath),'default',filePath.split('/').pop());this.uploadedFiles.push(fileResponse.file_id);console.log(`Uploaded: ${filePath} (ID: ${fileResponse.file_id})`);returnfileResponse.file_id;}catch(error){console.error(`Failed to upload ${filePath}:`,error);throwerror;}}asyncanalyze(query: string,analysisType: 'summary'|'questions'|'insights'='insights'): Promise<string>{constinstructions={summary: 'You are an expert document summarizer. Provide clear, concise summaries.',questions: 'You are an expert analyst. Answer questions based on the provided documents with citations.',insights: 'You are a research analyst. Extract key insights, patterns, and important findings.'};constresult=awaitthis.client.conversations.create({model: 'spec-3-turbo',instructions: instructions[analysisType],input: query,files: this.uploadedFiles.map(id=>({type: 'file', id })),temperature: 0.3,// Lower temperature for more factual responses});console.log(result.output);returnresult.output;}asynccompareDocuments(query: string): Promise<string>{if(this.uploadedFiles.length<2){thrownewError('Need at least 2 documents to compare');}returnthis.analyze(`Compare and contrast the documents regarding: ${query}`,'insights');}getUploadedFileIds(): string[]{return[...this.uploadedFiles];}}// Usageconstanalyzer=newDocumentAnalyzer();// Add multiple documentsawaitanalyzer.addDocument('./reports/quarterly-report.pdf');awaitanalyzer.addDocument('./reports/annual-summary.docx');// Analyze documentsconstsummary=awaitanalyzer.analyze('Provide a comprehensive summary of all documents','summary');console.log(' Summary:',summary);constinsights=awaitanalyzer.analyze('What are the key business decisions and their potential impact?','insights');console.log('💡 Insights:',insights);// Recommended: Clean and simpleconstresult=awaitclient.conversations.create({model: 'spec-3-turbo',instructions: 'You are a helpful assistant.',input: userMessage,});// More complex: Manual role managementconstresult=awaitclient.chat.create({model: 'spec-3-turbo',messages: [{role: 'system',content: 'You are a helpful assistant.'},{role: 'user',content: userMessage}],});try{constresult=awaitclient.conversations.create({...});}catch(error){if(errorinstanceofRateLimitError){awaitnewPromise(resolve=>setTimeout(resolve,Math.pow(2,retryCount)*1000));}}// For quick responses
model: 'spec-3-turbo'// For complex reasoning
model: 'theta-35'// For simple tasks
model: 'theta-35-mini'constfileId=awaitclient.files.create(document,'default');constresult1=awaitclient.conversations.create({files: [{type: 'file',id: fileId}],});constclient=newSVECTOR({apiKey: process.env.SVECTOR_API_KEY,});npm testWe welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
MIT License - see LICENSE file for details.
- Website: https://www.svector.co.in
- Documentation: API Reference
- Issues: GitHub Issues
- Support: support@svector.co.in
- npm Package: svector-sdk
Built with ❤️ by SVECTOR Corporation - Pushing the boundaries of AI, Mathematics, and Computational research