venice-dev-tools

Troubleshooting

This guide helps you resolve common issues you might encounter when using the Venice Dev Tools SDK.

Authentication Issues

Invalid API Key

Symptom: You receive an AuthError with a message like “Invalid API key provided.”

Solution:

  1. Verify that you’re using a valid API key:

    const venice = new VeniceNode({
      apiKey: 'your-api-key', // Check this value
    });
    
  2. Ensure your API key is active by checking its status in the Venice AI dashboard.

  3. Try regenerating your API key from the Venice AI website.

  4. For CLI usage, reconfigure your API key:

    venice configure
    

API Key Not Found

Symptom: You receive an error like “API key not found” when using the CLI.

Solution:

  1. Configure your API key:

    venice configure
    
  2. Check if the API key is properly stored:

    venice configure --show
    
  3. If using environment variables, ensure VENICE_API_KEY is set:

    export VENICE_API_KEY=your-api-key
    

Rate Limiting

Rate Limit Exceeded

Symptom: You receive a RateLimitError with a message like “Rate limit exceeded.”

Solution:

  1. Check your current rate limits:

    const rateLimits = await venice.keys.rateLimits();
    console.log(rateLimits);
    
  2. Implement retry logic with exponential backoff:

    async function retryWithBackoff(fn, maxRetries = 3) {
      let retries = 0;
      let delay = 1000; // Start with 1 second delay
         
      while (retries < maxRetries) {
        try {
          return await fn();
        } catch (error) {
          if (error instanceof RateLimitError) {
            retries++;
            if (retries >= maxRetries) throw error;
               
            console.log(`Rate limited. Retrying in ${delay}ms...`);
            await new Promise(resolve => setTimeout(resolve, delay));
            delay *= 2; // Exponential backoff
          } else {
            throw error;
          }
        }
      }
    }
    
  3. Consider upgrading your plan for higher rate limits.

Network Issues

Connection Errors

Symptom: You receive a NetworkError with messages like “Connection refused” or “Network error.”

Solution:

  1. Check your internet connection.

  2. Verify that you can access the Venice AI API:

    curl -I https://api.venice.ai/v1/health
    
  3. If you’re behind a proxy or firewall, ensure it allows connections to the Venice AI API.

  4. Implement retry logic for transient network issues:

    async function retryNetworkErrors(fn, maxRetries = 3) {
      let retries = 0;
         
      while (retries < maxRetries) {
        try {
          return await fn();
        } catch (error) {
          if (error instanceof NetworkError) {
            retries++;
            if (retries >= maxRetries) throw error;
               
            const delay = 1000 * retries; // Increasing delay
            console.log(`Network error. Retrying in ${delay}ms...`);
            await new Promise(resolve => setTimeout(resolve, delay));
          } else {
            throw error;
          }
        }
      }
    }
    

Timeout Errors

Symptom: You receive a TimeoutError with a message like “Request timed out.”

Solution:

  1. Increase the timeout in your SDK configuration:

    const venice = new VeniceNode({
      apiKey: 'your-api-key',
      timeout: 120000 // 120 seconds
    });
    
  2. For large requests or complex prompts, consider breaking them into smaller chunks.

Model-Specific Issues

Model Not Found

Symptom: You receive a ValidationError with a message like “Model not found.”

Solution:

  1. Check the available models:

    const models = await venice.models.list();
    console.log(models.map(model => model.id));
    
  2. Ensure you’re using a valid model ID:

    const response = await venice.chat.createCompletion({
      model: 'llama-3.3-70b', // Check this value
      messages: [{ role: 'user', content: 'Hello' }]
    });
    

Content Filtering

Symptom: You receive a response that indicates content was filtered or rejected.

Solution:

  1. Review your prompt for potentially problematic content.

  2. Rephrase your prompt to avoid triggering content filters.

  3. If you believe this is a false positive, contact Venice AI support.

Streaming Issues

Stream Disconnections

Symptom: Your stream disconnects unexpectedly during a streaming response.

Solution:

  1. Implement error handling for stream disconnections:

    try {
      const stream = await venice.chat.createCompletionStream({
        model: 'llama-3.3-70b',
        messages: [{ role: 'user', content: 'Write a long story' }]
      });
         
      let fullResponse = '';
         
      for await (const chunk of stream) {
        try {
          const content = chunk.choices[0]?.delta?.content || '';
          fullResponse += content;
          process.stdout.write(content);
        } catch (error) {
          console.error('Error processing chunk:', error);
        }
      }
    } catch (error) {
      if (error instanceof StreamError) {
        console.error('Stream error:', error.message);
      } else {
        console.error('Unexpected error:', error);
      }
    }
    
  2. Consider implementing reconnection logic for long-running streams.

CLI Issues

Command Not Found

Symptom: You receive a “command not found” error when trying to use the CLI.

Solution:

  1. Ensure the package is installed globally:

    npm install -g venice-dev-tools
    
  2. Check if the package is in your PATH:

    which venice
    
  3. If needed, add the npm global bin directory to your PATH.

CLI Permissions

Symptom: You receive a permission error when running CLI commands.

Solution:

  1. On Unix-like systems, ensure the CLI has execute permissions:

    chmod +x $(which venice)
    
  2. On Windows, check your execution policy if using PowerShell:

    Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
    

PDF Processing Issues

Text Extraction Error

Symptom: You receive an error like “Error extracting text from PDF: ENOENT: no such file or directory, open ‘./test/data/05-versions-space.pdf’” when using --pdf-mode text or --pdf-mode both.

Solution:

  1. This is a known issue with the current implementation. Try these workarounds:

    // Option 1: Use an external PDF text extraction tool
    // Extract text from PDF using an external tool like pdftotext
    const { execSync } = require('child_process');
    const extractedText = execSync(`pdftotext document.pdf -`).toString();
       
    // Then use the extracted text with the API
    const response = await venice.chat.createCompletion({
      model: 'llama-3.3-70b',
      messages: [
        { role: 'user', content: `Analyze this text: ${extractedText}` }
      ]
    });
    
  2. For CLI usage, extract the text first and then use it:

    # Extract text from PDF
    pdftotext document.pdf document.txt
       
    # Then use the text file
    venice chat --attach document.txt "Summarize this document"
    

PDF-to-Image Conversion Issues

Symptom: The default image mode doesn’t actually convert PDFs to images but sends them as binary data, which may not work well with all models.

Solution:

  1. Use an external library for proper PDF-to-image conversion:

    // Using pdf-img-convert library
    const pdfImgConvert = require('pdf-img-convert');
    const pdfImages = await pdfImgConvert.convert('./document.pdf', {
      width: 1024,
      height: 1450
    });
       
    // Save the first page as PNG
    fs.writeFileSync('document-page-1.png', pdfImages[0]);
       
    // Then use the image with a vision model
    const imageBuffer = fs.readFileSync('document-page-1.png');
    const base64Image = imageBuffer.toString('base64');
    
  2. For CLI usage, convert the PDF to images first:

    # Using ImageMagick
    convert -density 150 document.pdf -quality 90 document.png
       
    # Then use the image
    venice chat --attach document.png "Analyze this image"
    

Multiple File Attachments Alternative

Symptom: PDF processing modes don’t work as expected.

Solution:

  1. Use multiple file attachments as an alternative:

    // Extract text from PDF using an external tool
    const extractedText = fs.readFileSync('document-text.txt', 'utf8');
       
    // Convert PDF to image using an external tool
    const imageBuffer = fs.readFileSync('document-image.png');
       
    // Send both to the model
    const response = await venice.chat.createCompletion({
      model: 'llama-3.3-70b',
      messages: [
        {
          role: 'user',
          content: [
            { type: 'text', text: 'Analyze this document: ' + extractedText },
            { type: 'image', image: imageBuffer.toString('base64') }
          ]
        }
      ]
    });
    
  2. For CLI usage:

    # Attach both a text file and an image file
    venice chat --attach ./document.txt,./document.png --prompt "Analyze these files"
    

General PDF Processing Issues

Symptom: PDF processing fails with other errors.

Solution:

  1. Check if the PDF is valid and not corrupted:

    // Check file size before processing
    const stats = fs.statSync('document.pdf');
    console.log(`File size: ${stats.size} bytes`);
       
    // Try with a different PDF if possible
    
  2. Try processing specific pages instead of the entire document:

    const result = await venice.pdf.process({
      pdf: base64Pdf,
      mode: 'text',
      pages: '1-5' // Process only the first 5 pages
    });
    
  3. If the PDF is large, try processing it in chunks.

Vision/Multimodal Issues

Image Processing Fails

Symptom: Vision model fails to process images.

Solution:

  1. Check if you’re using a vision-capable model:

    // Use a model with vision capabilities
    const response = await venice.chat.createCompletion({
      model: 'claude-3-opus', // Must support vision
      messages: [
        {
          role: 'user',
          content: [
            { type: 'text', text: 'What's in this image?' },
            { type: 'image', image: base64Image }
          ]
        }
      ]
    });
    
  2. Verify the image format and size:

    // Check image details
    const imageBuffer = fs.readFileSync('image.jpg');
    console.log(`Image size: ${imageBuffer.length} bytes`);
       
    // Resize or compress the image if needed
    
  3. Ensure the base64 encoding is correct:

    const base64Image = imageBuffer.toString('base64');
    // Verify the base64 string starts correctly
    console.log(base64Image.substring(0, 50) + '...');
    

Debugging

Enable Debug Logging

To get more information about what’s happening:

const venice = new VeniceNode({
  apiKey: 'your-api-key',
  logLevel: 'debug' // Set to 'debug' for maximum information
});

Check SDK Version

Ensure you’re using the latest version:

npm list venice-dev-tools
npm list -g venice-dev-tools # For global installation

Update if needed:

npm update venice-dev-tools
npm update -g venice-dev-tools # For global installation

Inspect Request/Response

For detailed debugging, you can inspect the raw request and response:

const venice = new VeniceNode({
  apiKey: 'your-api-key',
  logLevel: 'debug',
  logger: {
    debug: (message, data) => {
      if (data?.request) {
        console.log('Request:', JSON.stringify(data.request, null, 2));
      }
      if (data?.response) {
        console.log('Response:', JSON.stringify(data.response, null, 2));
      }
      console.debug(message);
    },
    info: console.info,
    warn: console.warn,
    error: console.error
  }
});

Getting Help

If you’re still experiencing issues:

  1. Check the GitHub repository for known issues.

  2. Search for similar issues in the repository’s Issues section.

  3. Contact Venice AI support with details about your problem, including:

    • SDK version
    • Error messages
    • Code sample that reproduces the issue
    • Environment details (Node.js version, OS)