n8n-nodes-revenium
v0.1.8
Published
n8n community node for OpenAI ChatCompletion with automatic Revenium usage tracking
Readme
Revenium AI Agent for n8n
Drop-in replacement for n8n AI Agent with automatic Revenium usage tracking
A drop-in replacement for the standard n8n AI Agent with all the same capabilities, plus automatic AI cost tracking powered by Revenium. Track costs by customer, agent, or task. Enable usage-based billing and spending alerts to ensure you're never surprised by unexpected AI costs.
Overview
This custom node provides seamless integration between OpenAI's ChatCompletion API and Revenium's AI cost tracking & alerting platform. Track AI costs in n8n by customer, agent, task, and more. Extend cost-tracking into usage-based billing with automatic Stripe integration.
Features
- OpenAI ChatCompletion Integration: Full support for OpenAI's chat completion API
- Automatic Revenium Tracking: Fire-and-forget usage tracking with Revenium
- Token Usage Monitoring: Tracks prompt tokens, completion tokens, and total usage
- Cost & Performance Metrics: Monitors request duration and response times
- Transparent Workflow Integration: Returns OpenAI responses immediately while tracking usage asynchronously
Quick Start
Installation
For detailed instructions, see the official n8n community nodes installation guide.
Method 1: GUI Installation (Recommended)
- Go to Settings > Community Nodes
- Select Install
- Enter the npm package name:
n8n-nodes-revenium - Agree to the risks of installing unverified community nodes
- Select Install
- Search for "Revenium" in the node panel
Method 2: Manual Installation
# Navigate to your n8n custom nodes directory
cd ~/.n8n/custom
npm install n8n-nodes-revenium
# Restart n8nSee manual installation guide for details.
Method 3: Docker Deployment
FROM n8nio/n8n:latest
USER root
RUN npm install -g n8n-nodes-revenium
USER nodeNote: Community node installation from npm is only available on self-hosted n8n instances.
Verify Installation
After installation, verify the nodes are available:
- Restart n8n (if not done automatically)
- Open n8n in your browser
- Search for "Revenium" in the node panel
- You should see:
- Revenium AI Agent (drop-in replacement for n8n AI Agent)
- Revenium OpenAI Chat Model (with automatic usage tracking)
Configuration
Credentials Setup
Required Credentials:
OpenAI API Key:
- Get from OpenAI Platform
- Ensure it has access to the models you want to use
Revenium API Key:
- Sign up at Revenium for AI cost tracking
- Get your API key from the Revenium dashboard
- Free tier available for getting started
Setting Up Credentials in n8n:
- Go to: n8n → Credentials → Add Credential
- Search for: "Revenium OpenAI"
- Enter:
- OpenAI API Key: Your OpenAI key
- OpenAI Base URL: Leave default (
https://api.openai.com/v1) unless using Azure OpenAI or custom endpoint - Revenium API Key: Your Revenium key
- Revenium Metering Base URL: Leave default (
https://api.revenium.ai) unless using custom instance
Node Parameters
- The Revenium n8n Agent is a drop in replacement for the standard n8n AI Agent. It has the same parameters and functionality, with the addition of Revenium credentials to enable metadata tracking in Revenium for all AI operations.
Usage
Quick Setup for Chat Conversations
- Add a Chat Trigger: Search for "When chat message received" and add it to your workflow
- Add Revenium AI Agent: Search for "Revenium AI Agent" and connect it to the Chat Trigger
- Add Revenium OpenAI Chat Model: Connect it to the "Chat Model*" input on the AI Agent
- Configure credentials: Set up your OpenAI and Revenium API keys in the Chat Model
- Activate workflow: Your AI Agent is now ready for chat conversations!
What You Get
- Automatic chat handling: Users send messages → AI responds intelligently
- Transparent Revenium tracking: All OpenAI usage automatically tracked in background
- Memory support: Add a Memory node to maintain conversation history
- Tool integration: Connect Tools for enhanced AI capabilities (Calculator, Wikipedia, etc.)
Workflow Structure
When chat message received → Revenium AI Agent → [Response to user]
↓
Revenium OpenAI Chat Model
↓
[Memory] (optional)
↓
[Tools] (optional)Output
The Revenium AI Agent returns:
{
"response": "The AI response content",
"message": "The AI response content",
"full_response": {...},
"tool_calls": [],
"revenium_tracking": "Chat model automatically tracked via Revenium OpenAI Chat Model",
"conversation_saved": true,
"tools_executed": 0
}Tool Metering
Track execution of custom tools and external API calls with automatic timing, error handling, and metadata collection.
Quick Example
import { meterTool, setToolContext } from "n8n-nodes-revenium";
// Set context once (propagates to all tool calls)
setToolContext({
agent: "my-agent",
traceId: "session-123"
});
// Wrap tool execution
const result = await meterTool("weather-api", async () => {
return await fetch("https://api.example.com/weather");
}, {
operation: "get_forecast",
outputFields: ["temperature", "humidity"]
});
// Automatically extracts temperature & humidity from resultFunctions
meterTool(toolId, fn, metadata?)
- Wraps a function with automatic metering
- Captures duration, success/failure, and errors
- Returns function result unchanged
reportToolCall(toolId, report)
- Manually report a tool call that was already executed
- Useful when wrapping isn't possible
Context Management
setToolContext(ctx)- Set context for all subsequent tool callsgetToolContext()- Get current contextclearToolContext()- Clear contextrunWithToolContext(ctx, fn)- Run function with scoped context
Metadata Options
| Field | Description |
|-------|-------------|
| operation | Tool operation name (e.g., "search", "scrape") |
| outputFields | Array of field names to auto-extract from result |
| usageMetadata | Custom metrics (e.g., tokens, results count) |
| agent, traceId, etc. | Context fields (inherited from setToolContext) |
Troubleshooting
Node Not Appearing in n8n
- Restart n8n after installation
- Hard refresh your browser (Ctrl+Shift+R / Cmd+Shift+R)
- Check installation: In n8n → Settings → Community Nodes
- Verify package:
npm list n8n-nodes-reveniumin your n8n directory
OpenAI API Errors
- Verify your OpenAI API key is valid and has sufficient credits
- Check the model name matches OpenAI's available models
- Ensure your API key has access to the selected model
Revenium Tracking Issues
- Verify credentials: Check your Revenium API key is correct
- Check connectivity: Ensure n8n can reach
https://api.revenium.ai - Review logs: Check n8n logs for Revenium API error messages
- Test separately: Verify your Revenium API key works outside n8n
Getting Help
- Documentation: Revenium Documentation
- Support: Contact Revenium support for API key or tracking issues
- Community: n8n Community Forum for general n8n questions
Documentation
For detailed documentation, visit docs.revenium.io
Security
Report security vulnerabilities to [email protected] (do not create public issues).
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For issues, feature requests, or contributions:
- Website: www.revenium.ai
- GitHub Repository: revenium/revenium-middleware-openai-n8n
- Issues: Report bugs or request features
- Documentation: docs.revenium.io
- Email: [email protected]
Built by Revenium
