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 .env file 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+
  • requests library: 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:

๐Ÿ”’ Security Best Practices

  1. Never hardcode API keys in scripts or commit them to version control
  2. Use environment variables for sensitive credentials
  3. Rotate API keys regularly in production environments
  4. Monitor your usage through the Venice.ai dashboard
  5. Use .env files with proper .gitignore entries for local development

๐Ÿ“š Next Steps

After verifying your API works:

  1. Check the OpenAPI Specification for complete API documentation
  2. Read the Quick Start Guide for more examples
  3. Explore advanced features like web search, vision, and function calling
  4. Review the README for SDK generation and integration options

๐Ÿ’ฌ Support


Happy Testing! ๐Ÿš€