Venice.ai API - Live Test Examples
October 2, 2025 ยท View on GitHub
This directory contains runnable test scripts to verify that the Venice.ai API is working correctly with your API key.
๐ Setup
Before running any tests, you need to set your Venice.ai API key as an environment variable:
export VENICE_API_KEY=your-api-key-here
Alternatively, you can copy .env.example to .env and set your API key there (if using a tool that loads .env files):
cp .env.example .env
# Edit .env and add your actual API key
Get your API key from the Venice.ai Dashboard.
โ ๏ธ Security Note: Never commit your API key to version control. These scripts read the key from environment variables only. The
.envfile is already in.gitignore.
๐งช Available Tests
1. Basic Chat Completion
Test the basic chat completion endpoint with a simple message.
JavaScript (Node.js 18+):
node test-chat.js
Python 3:
python3 test-chat.py
Bash/cURL:
bash test-chat.sh
2. Streaming Chat
Test the streaming API to see real-time token generation.
JavaScript:
node test-streaming.js
๐ Requirements
For JavaScript tests:
- Node.js 18+ (for native fetch support)
- No additional packages required
For Python tests:
- Python 3.6+
requestslibrary:pip install requests
For Bash tests:
- bash
- curl
- jq (for JSON parsing)
๐ฏ What These Tests Verify
โ
API endpoint connectivity
โ
Authentication with your API key
โ
Basic chat completion functionality
โ
Streaming response handling
โ
Response parsing and error handling
๐ Expected Output
All tests should output:
- โ Success confirmation
- The model used
- The AI's response content
- Token usage statistics
Example:
๐ Testing Venice.ai Chat Completion API...
โ
Success! Response received:
Model: venice-uncensored
Content: Venice API is working! How can I assist you today?
Usage:
Prompt tokens: 15
Completion tokens: 12
Total tokens: 27
๐ Venice.ai API is working correctly!
โ Troubleshooting
"VENICE_API_KEY environment variable is not set"
Make sure you've exported your API key:
export VENICE_API_KEY=your-api-key-here
"401 Unauthorized"
Your API key is invalid or expired. Get a new one from Venice.ai Dashboard.
"429 Rate Limited"
You've exceeded your rate limit. Wait a moment and try again.
Node.js fetch not available
Make sure you're using Node.js 18 or later, which includes native fetch support.
Python requests module not found
Install the requests library:
pip install requests
Bash jq not found
Install jq for JSON parsing:
- Ubuntu/Debian:
sudo apt-get install jq - macOS:
brew install jq - Other: See jq installation guide
๐ Security Best Practices
- Never hardcode API keys in scripts or commit them to version control
- Use environment variables for sensitive credentials
- Rotate API keys regularly in production environments
- Monitor your usage through the Venice.ai dashboard
- Use
.envfiles with proper.gitignoreentries for local development
๐ Next Steps
After verifying your API works:
- Check the OpenAPI Specification for complete API documentation
- Read the Quick Start Guide for more examples
- Explore advanced features like web search, vision, and function calling
- Review the README for SDK generation and integration options
๐ฌ Support
- ๐ Documentation: docs.venice.ai
- ๐ฌ Support: support@venice.ai
- ๐ Issues: GitHub Issues
Happy Testing! ๐