Installation Guide
Detailed installation instructions for PrecogX SDK and integrations.
System Requirements
Python
- Python 3.8 or higher
- pip package manager
Node.js
- Node.js 16.0 or higher
- npm or yarn package manager
Other Languages
- REST API support for any language with HTTP capabilities
Python Installation
Standard Installation
pip install precogx-sdk
With Framework Support
# For LangChain integration
pip install "precogx-sdk[langchain]"
# For AutoGen integration
pip install "precogx-sdk[autogen]"
# For CrewAI integration
pip install "precogx-sdk[crewai]"
Virtual Environment (Recommended)
# Create virtual environment
python -m venv precogx-env
# Activate virtual environment
# On Windows:
precogx-env\Scripts\activate
# On macOS/Linux:
source precogx-env/bin/activate
# Install PrecogX SDK
pip install precogx-sdk
Verify Installation
import precogx_sdk
print(f"PrecogX SDK version: {precogx_sdk.__version__}")
Node.js Installation
Using npm
npm install @precogx/sdk
Using yarn
yarn add @precogx/sdk
Verify Installation
const { PrecogXClient } = require('@precogx/sdk');
console.log('PrecogX SDK installed successfully');
Framework Integrations
LangChain
from precogx_sdk.langchain import PrecogXCallbackHandler
from langchain.llms import OpenAI
# Initialize LangChain with PrecogX
llm = OpenAI(temperature=0)
handler = PrecogXCallbackHandler(api_key="your_api_key")
# Use in your chain
llm.call("Hello world", callbacks=[handler])
AutoGen
from precogx_sdk.autogen import PrecogXAgent
import autogen
# Create PrecogX-protected agent
agent = PrecogXAgent(
name="assistant",
api_key="your_api_key",
system_message="You are a helpful assistant."
)
CrewAI
from precogx_sdk.crewai import PrecogXAgent
from crewai import Task, Crew
# Create PrecogX-protected agent
agent = PrecogXAgent(
role="Researcher",
goal="Research topics",
backstory="You are a research assistant",
api_key="your_api_key"
)
No-Code Platforms
Flowise
- Add HTTP Request node
- Configure endpoint:
https://api.precogx.ai/v1/telemetry - Set method to POST
- Add headers:
Authorization: Bearer YOUR_API_KEY
Dify
- Navigate to Tools section
- Add Custom Tool
- Configure webhook URL:
https://api.precogx.ai/v1/telemetry - Add authentication headers
n8n
- Add HTTP Request node
- Set URL:
https://api.precogx.ai/v1/telemetry - Add Authorization header
- Configure request body
Langflow
- Add Custom Component
- Configure API endpoint
- Add authentication
- Map input/output fields
Environment Configuration
Environment Variables
Create a .env file:
PRECOGX_API_KEY=your_api_key_here
PRECOGX_BASE_URL=https://api.precogx.ai
PRECOGX_ENVIRONMENT=production
Python Configuration
import os
from precogx_sdk import PrecogXClient
# Load from environment
api_key = os.getenv('PRECOGX_API_KEY')
client = PrecogXClient(api_key=api_key)
Node.js Configuration
const { PrecogXClient } = require('@precogx/sdk');
// Load from environment
const apiKey = process.env.PRECOGX_API_KEY;
const client = new PrecogXClient(apiKey);
Docker Installation
Python Dockerfile
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"]
requirements.txt
precogx-sdk==1.0.0
fastapi==0.104.1
uvicorn==0.24.0
Troubleshooting
Common Issues
Import Error
# Ensure you're using the correct Python environment
which python
pip list | grep precogx
Authentication Error
# Verify your API key
client = PrecogXClient(api_key="your_key")
print(client.health_check())
Network Issues
# Check connectivity
import requests
response = requests.get("https://api.precogx.ai/health")
print(response.status_code)
Getting Help
Next Steps
- First Agent - Create your first protected agent