Installation & Setup
Installation & Setup
This guide covers installing the Rizk SDK across different environments and setting up your first integration.
Quick Installation
For most users, the simplest installation method is using pip:
pip install rizk
Installation Options
Standard Installation
The standard installation includes the core SDK with basic functionality:
# Standard installationpip install rizk
# With specific versionpip install rizk==0.1.0
# Upgrade to latest versionpip install --upgrade rizk
Framework-Specific Installations
Install with optional dependencies for specific frameworks:
# For LangChain integrationpip install rizk[langchain]
# For CrewAI integrationpip install rizk[crewai]
# For LlamaIndex integrationpip install rizk[llama-index]
# For all framework integrationspip install rizk[all]
Development Installation
For contributors or advanced users who want the latest features:
# Clone the repositorygit clone https://github.com/rizk-tools/rizk-sdk.gitcd rizk-sdk
# Install in development modepip install -e .
# Install with development dependenciespip install -e .[dev]
System Requirements
Python Version
- Python 3.10 or higher (tested on 3.10, 3.11, 3.12, 3.13)
- Operating Systems: Windows, macOS, Linux
Core Dependencies
The SDK automatically installs these core dependencies:
traceloop-sdk
- OpenTelemetry integrationopentelemetry-*
- Observability instrumentationpydantic
- Data validation and serializationcolorama
- Cross-platform colored terminal outputpyyaml
- YAML configuration file support
Optional Dependencies
Framework-specific dependencies (installed with extras):
# LangChain ecosystempip install rizk[langchain] # Installs: langchain, langchain-openai, langchain-community
# CrewAI ecosystempip install rizk[crewai] # Installs: crewai, crewai-tools
# LlamaIndex ecosystempip install rizk[llama-index] # Installs: llama-index, llama-index-core
# OpenAI integrationpip install rizk[openai] # Installs: openai>=1.0.0
# Anthropic integrationpip install rizk[anthropic] # Installs: anthropic
# All integrationspip install rizk[all] # Installs all optional dependencies
Environment Setup
1. API Key Configuration
Rizk requires an API key for operation. Set it using one of these methods:
Environment Variable (Recommended):
# Windows PowerShell$env:RIZK_API_KEY="your-api-key-here"
# Windows Command Promptset RIZK_API_KEY=your-api-key-here
# Linux/macOSexport RIZK_API_KEY="your-api-key-here"
Configuration File:
Create a .env
file in your project root:
RIZK_API_KEY=your-api-key-hereRIZK_APP_NAME=my-applicationRIZK_ENABLED=true
Programmatic Configuration:
from rizk.sdk import Rizk
rizk = Rizk.init( app_name="MyApp", api_key="your-api-key-here", # Direct usage of API Keys not recommended for production or development enabled=True)
2. OpenTelemetry Configuration (Optional)
Configure custom OpenTelemetry endpoints if needed:
# Custom OTLP endpointexport RIZK_OPENTELEMETRY_ENDPOINT="https://your-otlp-endpoint.com"
# Disable telemetry entirelyexport RIZK_TRACING_ENABLED=false
3. Policy Configuration (Optional)
Set custom policy directories:
# Custom policies directoryexport RIZK_POLICIES_PATH="/path/to/your/policies"
# Disable policy enforcementexport RIZK_POLICY_ENFORCEMENT=false
Installation Verification
Verify your installation with this simple test:
from rizk.sdk import Rizkfrom rizk.sdk.decorators import workflow
# Initialize SDKrizk = Rizk.init( app_name="InstallationTest", api_key="test-key", enabled=True)
# Test decorator@workflow(name="test_workflow", organization_id="test", project_id="test")def test_function(): return "Rizk SDK is working!"
# Run testresult = test_function()print(f"✅ Installation successful: {result}")
Run the test:
python test_installation.py
Expected output:
✅ Installation successful: Rizk SDK is working!
Framework-Specific Setup
OpenAI Agents SDK
# Install Rizk with OpenAI supportpip install rizk[openai]
# Set OpenAI API key (if using OpenAI LLMs)export OPENAI_API_KEY="your-openai-api-key"
from rizk.sdk import Rizkfrom rizk.sdk.decorators import tool, workflowfrom agents import Agent, Runner
# Initialize Rizkrizk = Rizk.init(app_name="OpenAI-Agents-App", enabled=True)
@tool(name="calculator")def calculate(expression: str) -> str: return str(eval(expression))
agent = Agent( name="MathBot", instructions="You are a helpful math assistant", tools=[calculate])
@workflow(name="math_workflow")async def run_agent(query: str): result = await Runner.run(agent, query) return result.final_output
LangChain
# Install Rizk with LangChain supportpip install rizk[langchain]
from rizk.sdk import Rizkfrom rizk.sdk.decorators import workflow, toolfrom langchain.agents import AgentExecutor, create_openai_tools_agentfrom langchain_openai import ChatOpenAI
# Initialize Rizkrizk = Rizk.init(app_name="LangChain-App", enabled=True)
@tool(name="weather_tool")def get_weather(city: str) -> str: return f"Weather in {city}: Sunny, 75°F"
llm = ChatOpenAI()tools = [get_weather]agent = create_openai_tools_agent(llm, tools, "You are a weather assistant")agent_executor = AgentExecutor(agent=agent, tools=tools)
@workflow(name="weather_workflow")def run_weather_agent(query: str): return agent_executor.invoke({"input": query})["output"]
CrewAI
# Install Rizk with CrewAI supportpip install rizk[crewai]
from rizk.sdk import Rizkfrom rizk.sdk.decorators import crew, task, agentfrom crewai import Agent, Task, Crew, Process
# Initialize Rizkrizk = Rizk.init(app_name="CrewAI-App", enabled=True)
@agent(name="researcher")def create_researcher(): return Agent( role="Researcher", goal="Research topics thoroughly", backstory="You are an expert researcher", verbose=True )
@task(name="research_task")def create_research_task(agent, topic): return Task( description=f"Research {topic} comprehensively", agent=agent, expected_output="A detailed research report" )
@crew(name="research_crew")def create_crew(): researcher = create_researcher() task = create_research_task(researcher, "AI trends")
return Crew( agents=[researcher], tasks=[task], process=Process.sequential, verbose=True )
Virtual Environment Setup
For production deployments, use virtual environments:
Using venv (Python standard library)
# Create virtual environmentpython -m venv rizk-env
# Activate (Windows)rizk-env\Scripts\activate
# Activate (Linux/macOS)source rizk-env/bin/activate
# Install Rizkpip install rizk
# Deactivate when donedeactivate
Using conda
# Create conda environmentconda create -n rizk-env python=3.11
# Activate environmentconda activate rizk-env
# Install Rizkpip install rizk
# Deactivate when doneconda deactivate
Using Poetry (Recommended for Development)
# Initialize Poetry projectpoetry init
# Add Rizk dependencypoetry add rizk
# Install dependenciespoetry install
# Run in Poetry environmentpoetry run python your_script.py
Example pyproject.toml
:
[tool.poetry]name = "my-rizk-app"version = "0.1.0"description = "My application using Rizk SDK"
[tool.poetry.dependencies]python = "^3.10"rizk = "^0.1.0"langchain = { version = "^0.1.0", optional = true }crewai = { version = "^0.1.0", optional = true }
[tool.poetry.extras]langchain = ["langchain"]crewai = ["crewai"]all = ["langchain", "crewai"]
Docker Setup
For containerized deployments:
Basic Dockerfile
# DockerfileFROM python:3.11-slim
WORKDIR /app
# Install system dependenciesRUN apt-get update && apt-get install -y \ gcc \ && rm -rf /var/lib/apt/lists/*
# Copy requirementsCOPY requirements.txt .
# Install Python dependenciesRUN pip install --no-cache-dir -r requirements.txt
# Copy application codeCOPY . .
# Set environment variablesENV RIZK_API_KEY=""ENV RIZK_APP_NAME="dockerized-app"
# Run applicationCMD ["python", "main.py"]
requirements.txt
rizk==0.1.0# Add other dependencies as neededlangchain>=0.1.0openai>=1.0.0
Docker Compose
version: '3.8'
services: rizk-app: build: . environment: - RIZK_API_KEY=${RIZK_API_KEY} - RIZK_APP_NAME=my-dockerized-app - RIZK_TRACING_ENABLED=true ports: - "8000:8000" volumes: - ./policies:/app/policies:ro # Mount custom policies
Common Installation Issues
Issue 1: Python Version Compatibility
Error: ERROR: Package 'rizk' requires a different Python
Solution: Ensure you’re using Python 3.10 or higher:
python --version # Should be 3.10+pip --version # Should use the correct Python version
Issue 2: Dependency Conflicts
Error: ERROR: pip's dependency resolver does not currently have a backtracking strategy
Solutions:
# Option 1: Upgrade pippip install --upgrade pip
# Option 2: Use --force-reinstallpip install --force-reinstall rizk
# Option 3: Create fresh virtual environmentpython -m venv fresh-envfresh-env\Scripts\activate # Windowspip install rizk
Issue 3: Network/Proxy Issues
Error: ERROR: Could not fetch URL
Solutions:
# Configure proxy (if needed)pip install --proxy http://proxy.company.com:8080 rizk
# Use trusted hosts (if SSL issues)pip install --trusted-host pypi.org --trusted-host pypi.python.org rizk
# Upgrade certificatespip install --upgrade certifi
Issue 4: Permission Issues
Error: ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied
Solutions:
# Option 1: Install for user onlypip install --user rizk
# Option 2: Use virtual environment (recommended)python -m venv rizk-envrizk-env\Scripts\activatepip install rizk
Next Steps
After installation, proceed to:
- Quick Start Guide - Get up and running in 5 minutes
- First Example - Complete walkthrough with working code
- Configuration - Detailed configuration options
Getting Help
If you encounter issues:
- Check the Troubleshooting Guide
- Search GitHub Issues
- Join our Discord Community
- Contact Support
Supported Python Versions: 3.10, 3.11, 3.12
Supported Platforms: Windows, macOS, Linux
Installation Size: ~50MB (core), ~200MB (with all extras)