This guide helps you resolve common issues you might encounter when using the Venice Dev Tools SDK.
Symptom: You receive an AuthError with a message like “Invalid API key provided.”
Solution:
Verify that you’re using a valid API key:
const venice = new VeniceNode({
apiKey: 'your-api-key', // Check this value
});
Ensure your API key is active by checking its status in the Venice AI dashboard.
Try regenerating your API key from the Venice AI website.
For CLI usage, reconfigure your API key:
venice configure
Symptom: You receive an error like “API key not found” when using the CLI.
Solution:
Configure your API key:
venice configure
Check if the API key is properly stored:
venice configure --show
If using environment variables, ensure VENICE_API_KEY is set:
export VENICE_API_KEY=your-api-key
Symptom: You receive a RateLimitError with a message like “Rate limit exceeded.”
Solution:
Check your current rate limits:
const rateLimits = await venice.keys.rateLimits();
console.log(rateLimits);
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;
}
}
}
}
Consider upgrading your plan for higher rate limits.
Symptom: You receive a NetworkError with messages like “Connection refused” or “Network error.”
Solution:
Check your internet connection.
Verify that you can access the Venice AI API:
curl -I https://api.venice.ai/v1/health
If you’re behind a proxy or firewall, ensure it allows connections to the Venice AI API.
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;
}
}
}
}
Symptom: You receive a TimeoutError with a message like “Request timed out.”
Solution:
Increase the timeout in your SDK configuration:
const venice = new VeniceNode({
apiKey: 'your-api-key',
timeout: 120000 // 120 seconds
});
For large requests or complex prompts, consider breaking them into smaller chunks.
Symptom: You receive a ValidationError with a message like “Model not found.”
Solution:
Check the available models:
const models = await venice.models.list();
console.log(models.map(model => model.id));
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' }]
});
Symptom: You receive a response that indicates content was filtered or rejected.
Solution:
Review your prompt for potentially problematic content.
Rephrase your prompt to avoid triggering content filters.
If you believe this is a false positive, contact Venice AI support.
Symptom: Your stream disconnects unexpectedly during a streaming response.
Solution:
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);
}
}
Consider implementing reconnection logic for long-running streams.
Symptom: You receive a “command not found” error when trying to use the CLI.
Solution:
Ensure the package is installed globally:
npm install -g venice-dev-tools
Check if the package is in your PATH:
which venice
If needed, add the npm global bin directory to your PATH.
Symptom: You receive a permission error when running CLI commands.
Solution:
On Unix-like systems, ensure the CLI has execute permissions:
chmod +x $(which venice)
On Windows, check your execution policy if using PowerShell:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
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:
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}` }
]
});
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"
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:
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');
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"
Symptom: PDF processing modes don’t work as expected.
Solution:
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') }
]
}
]
});
For CLI usage:
# Attach both a text file and an image file
venice chat --attach ./document.txt,./document.png --prompt "Analyze these files"
Symptom: PDF processing fails with other errors.
Solution:
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
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
});
If the PDF is large, try processing it in chunks.
Symptom: Vision model fails to process images.
Solution:
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 }
]
}
]
});
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
Ensure the base64 encoding is correct:
const base64Image = imageBuffer.toString('base64');
// Verify the base64 string starts correctly
console.log(base64Image.substring(0, 50) + '...');
To get more information about what’s happening:
const venice = new VeniceNode({
apiKey: 'your-api-key',
logLevel: 'debug' // Set to 'debug' for maximum information
});
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
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
}
});
If you’re still experiencing issues:
Check the GitHub repository for known issues.
Search for similar issues in the repository’s Issues section.
Contact Venice AI support with details about your problem, including: