Package Information
Released: 6/30/2025
Downloads: 19 weekly / 142 monthly
Latest Version: 0.0.1
Author: sherman.zhou
Available Nodes
Documentation
n8n OpenAI Compatible Node
This n8n node allows you to interact with any OpenAI-compatible API service like qwen etc. It supports both chat completions and text completions, making it compatible with various AI model providers that follow the OpenAI API specification.
Features
- Chat Completions: Generate responses using the chat completion endpoint (
/v1/chat/completions
) - Text Completions: Generate text using the completion endpoint (
/v1/completions
) - Flexible Configuration: Configure base URL, model, and API key for any OpenAI-compatible service
- Advanced Parameters: Support for temperature, max tokens, top-p, frequency penalty, presence penalty, and stop sequences
- Error Handling: Robust error handling with continue-on-fail support
Supported Services
This node works with any service that implements the OpenAI API specification, including:
- OpenAI API
- Azure OpenAI
- Anthropic Claude (via OpenAI-compatible wrapper)
- Local models (Ollama, LM Studio, etc.)
- Other OpenAI-compatible providers
Installation
Manual Installation
- Clone or download this repository
- Install dependencies:
npm install
- Build the node:
npm run build
- Copy the
dist
folder to your n8n custom nodes directory:cp -r dist ~/.n8n/custom/
- Restart n8n
Using npm
npm install n8n-nodes-openai-compatible-node
Usage
1. Configure Credentials
- In n8n, go to Settings → Credentials
- Click Add Credential
- Search for "OpenAI Compatible API"
- Configure:
- Base URL: The base URL of your OpenAI-compatible service (e.g.,
https://api.openai.com
,https://your-service.com
) - API Key: Your API key for the service
- Base URL: The base URL of your OpenAI-compatible service (e.g.,
2. Add the Node
- In your workflow, add the "OpenAI Compatible" node
- Select the credentials you created
- Choose the operation:
- Chat Completion: For conversational AI responses
- Text Completion: For text generation
3. Configure Parameters
Chat Completion
- Model: The model name (e.g.,
gpt-3.5-turbo
,gpt-4
) - Messages: Array of messages with role (system, user, assistant) and content
- Additional Fields: Optional parameters like temperature, max tokens, etc.
Text Completion
- Model: The model name (e.g.,
text-davinci-003
) - Prompt: The text prompt to complete
- Additional Fields: Optional parameters like temperature, max tokens, etc.
4. Advanced Parameters
- Temperature (0-2): Controls randomness. Lower values = more deterministic
- Max Tokens: Maximum number of tokens to generate
- Top P (0-1): Controls diversity via nucleus sampling
- Frequency Penalty (-2 to 2): Penalizes new tokens based on frequency
- Presence Penalty (-2 to 2): Penalizes new tokens based on presence
- Stop: Sequences where generation stops
Examples
Chat Completion Example
{
"operation": "chatCompletion",
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello, how are you?"
}
],
"temperature": 0.7,
"max_tokens": 1000
}
Text Completion Example
{
"operation": "textCompletion",
"model": "text-davinci-003",
"prompt": "Write a short story about a robot learning to paint.",
"temperature": 0.8,
"max_tokens": 500
}
Configuration Examples
OpenAI API
- Base URL:
https://api.openai.com
- API Key: Your OpenAI API key
Azure OpenAI
- Base URL:
https://your-resource.openai.azure.com/openai/deployments/your-deployment
- API Key: Your Azure OpenAI API key
Local Ollama
- Base URL:
http://localhost:11434/v1
- API Key: (leave empty or use any value)
Anthropic Claude (via OpenAI wrapper)
- Base URL:
https://api.anthropic.com/v1
- API Key: Your Anthropic API key
Development
Prerequisites
- Node.js 16+
- npm or yarn
- n8n development environment
Setup
- Clone the repository
- Install dependencies:
npm install
- Build:
npm run build
- Link to n8n:
npm link
(in n8n directory)
Scripts
npm run build
: Build the nodenpm run dev
: Watch mode for developmentnpm run lint
: Run ESLintnpm run format
: Format code with Prettier
Troubleshooting
Common Issues
"Base URL and API Key are required"
- Ensure both fields are filled in the credentials
"At least one message is required for chat completion"
- Add at least one message in the Messages section
"Prompt is required for text completion"
- Add a prompt in the Prompt field
Authentication errors
- Verify your API key is correct
- Check if the base URL is accessible
Debug Mode
Enable debug logging in n8n to see detailed request/response information.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details.
Support
For issues and questions:
- Create an issue on GitHub
- Check the n8n documentation
- Join the n8n community