Skip to main content

Quick Setup

Get started with minimal configuration

External Services

Configure Twilio, DigiSigner, and more

Overview

CreditNexus uses environment variables for all configuration. Create a .env file in the project root directory with your settings. All sensitive values (API keys, secrets) are stored as SecretStr types in Pydantic settings for security. Configuration File: app/core/config.py

LLM Provider Configuration

CreditNexus supports multiple LLM providers: OpenAI (default), vLLM, and HuggingFace. You can also use local models with HuggingFace.

OpenAI Configuration

Required for all providers (used as fallback):
string
required
Your OpenAI API key. Get from https://platform.openai.com/api-keys
string
LLM provider: "openai", "vllm", or "huggingface". Default: "openai"
string
Model identifier. OpenAI: "gpt-4o", "gpt-4o-mini", "gpt-3.5-turbo". Default: "gpt-4o"
float
Temperature for generation (0.0 = deterministic, 1.0 = creative). Default: 0.0
Code Reference: app/core/llm_client.py - get_chat_model()

vLLM Configuration

For self-hosted vLLM servers:
string
Base URL for your vLLM server (e.g., "http://localhost:8000")
string
Optional API key if your vLLM server requires authentication
Example:

HuggingFace Configuration

HuggingFace supports both inference endpoints (API-based) and local models.
string
HuggingFace API token. Get from https://huggingface.co/settings/tokens
string
Custom base URL. Default: https://api-inference.huggingface.co/v1For Inference Providers router: https://router.huggingface.co/{provider}/v3/openai
string
Inference provider selection. Options:
  • "auto" (default): Selects first available provider from your preferences
  • "novita", "together", "sambanova", "fireworks-ai", "cohere", "fal-ai", "groq", "replicate", "hf-inference", "black-forest-labs", "cerebras", "featherless-ai", "hyperbolic", "nebius", "novita", "nscale", "openai"
Default: "novita" (preferred provider)
boolean
Set to true to load models locally using transformers (requires GPU/CPU resources). Set to false to use inference endpoints (API-based, no local resources needed).Default: false
Recommended Models for Novita:
  • meta-llama/Llama-3.1-8B-Instruct
  • microsoft/Phi-3.5-mini-instruct
  • deepseek-ai/DeepSeek-V3.2-Exp
Code Reference: app/core/llm_client.py - get_chat_model()

Embeddings Configuration

string
Embeddings model identifier.OpenAI: "text-embedding-3-small", "text-embedding-3-large", "text-embedding-ada-002"HuggingFace: "sentence-transformers/all-MiniLM-L6-v2" (22.7M params, lightweight), "BAAI/bge-small-en-v1.5" (33.4M params)Default: "text-embedding-3-small"
string
Embeddings provider: "openai", "huggingface", or leave empty to use LLM_PROVIDER.Default: "huggingface"
boolean
Use local embeddings model instead of API (HuggingFace only). Default: false
string
Device for local embeddings: "cpu", "cuda", "cuda:0", or "auto". Default: "cpu"
string
Additional model kwargs as JSON string. Examples:
  • '{"device_map":"auto"}'
  • '{"trust_remote_code":true}'
  • '{"device":"cuda","model_kwargs":{"torch_dtype":"float16"}}'
Code Reference: app/core/llm_client.py - get_embeddings_model()

SentinelHub Configuration

SentinelHub provides satellite imagery for verification workflows.
string
SentinelHub OAuth client ID. Get from https://www.sentinel-hub.com/
string
SentinelHub OAuth client secret. Get from https://www.sentinel-hub.com/
Setup Guide: See SentinelHub Setup Guide Code Reference: app/agents/verifier.py

Policy Engine Configuration

boolean
Enable policy engine for real-time compliance enforcement. Default: true
string
Directory containing policy rule YAML files. Default: app/policies
string
File pattern for policy rules. Default: *.yaml
string
Policy engine vendor (optional). Default: "" (uses default engine)
boolean
Auto-reload policy rules on file changes (development only). Default: false
Code Reference: app/core/policy_config.py, app/services/policy_service.py

Agent Workflows Configuration

CreditNexus includes three AI agent workflows: LangAlpha (quantitative analysis), DeepResearch (iterative web research), and PeopleHub (business intelligence). Configure API keys and settings for each workflow.

LangAlpha Configuration

LangAlpha performs quantitative financial analysis using multiple specialized agents.
string
Polygon.io API key for market data. Get from https://polygon.io/Required for: Market data fetching, ticker snapshots, historical data
string
Alpha Vantage API key for fundamental data. Get from https://www.alphavantage.co/support/#api-keyRequired for: Company fundamentals, financial statements, earnings data
string
Tavily API key for news/search. Get from https://tavily.com/Optional: Falls back to WebSearchService if not configured
string
Tickertick API key for financial news.Optional: Service may not be publicly available. Falls back to web_search tool or Tavily.
LLM Model Configuration:
string
LLM model for reasoning tasks (supervisor, planner, analyst). Default: "gpt-4o"
string
LLM model for basic tasks (researcher, reporter, market). Default: "gpt-4o-mini"
string
LLM model for economic analysis tasks. Default: "gpt-4o-mini"
string
LLM model for coding/calculation tasks. Default: "gpt-4o"
string
Budget level for LangAlpha agents: "low", "medium", or "high". Default: "medium"
  • low: Uses cheaper models, fewer iterations
  • medium: Balanced cost and quality
  • high: Uses premium models, more thorough analysis
Code Reference: app/workflows/langalpha_graph.py, app/services/quantitative_analysis_service.py Feature Documentation: Agent Workflows

DeepResearch Configuration

DeepResearch performs iterative web research with knowledge accumulation.
string
Serper API key for Google search. Get from https://serper.dev/Optional: Falls back to WebSearchService if not configured
WebSearchService Configuration:
integer
Web search rate limit (requests per hour). Default: 360
boolean
Enable caching for web search results. Default: true
integer
Web search cache TTL in hours. Default: 24
Code Reference: app/agents/deep_research_agent.py, app/services/deep_research_service.py Feature Documentation: Agent Workflows

Reranking Configuration

Reranking improves search result quality by reordering results based on relevance.
boolean
Use local reranking model (True) or remote API (False). Default: trueLocal: Uses sentence-transformers CrossEncoder (requires GPU/CPU resources) Remote: Uses API-based reranking (e.g., Cohere, Jina)
string
Local reranking model identifier (HuggingFace model ID). Default: "BAAI/bge-reranker-base"Alternatives:
  • "BAAI/bge-reranker-large" (better quality)
  • "cross-encoder/ms-marco-MiniLM-L-6-v2" (faster)
string
Device for local reranking: "cpu", "cuda", "cuda:0", etc. Default: "cpu"
string
Remote reranking API URL (only needed if RERANKING_USE_LOCAL=false).Examples:
  • Cohere: https://api.cohere.ai/v1/rerank
  • Jina: https://api.jina.ai/v1/rerank
string
Remote reranking API key (only needed if using remote reranking)
Code Reference: app/services/web_search_service.py

PeopleHub Configuration

PeopleHub provides business intelligence and psychometric analysis. No additional API keys required - Uses existing WebSearchService and LLM configuration. Code Reference: app/workflows/peoplehub_research_graph.py, app/services/digitizer_chatbot_service.py Feature Documentation: Agent Workflows

Agent Dashboard Configuration

The Agent Dashboard requires no additional configuration - it automatically displays results from all agent workflows. Code Reference: client/src/apps/agent-dashboard/AgentDashboard.tsx Feature Documentation: Agent Workflows

Database Configuration

string
required
PostgreSQL connection string:Format: postgresql://user:password@localhost:5432/creditnexusFor SQLite (development fallback): sqlite:///./creditnexus.db
boolean
Enable database connection. Default: true

Database SSL/TLS Configuration

For production, SSL/TLS encryption is required:
boolean
Require SSL/TLS for database connections. Default: false (development), true (production)
string
SSL mode: "prefer", "require", "verify-ca", "verify-full". Default: "prefer"
string
Path to SSL client certificate file (optional)
string
Path to SSL client key file (optional)
string
Path to SSL CA certificate file (required for verify-ca and verify-full modes)
boolean
Automatically generate self-signed certificates for development. Default: false
boolean
Auto-generate CA certificate. Default: true (when DB_SSL_AUTO_GENERATE=true)
boolean
Auto-generate client certificate for mutual TLS. Default: false
string
Certificate directory for auto-generated certificates. Default: "./ssl_certs/db"
integer
Certificate validity period in days. Default: 365
Setup Guide: See Database SSL Setup Guide and SSL Troubleshooting Guide Code Reference: app/core/config.py, app/db/ssl_config.py

Authentication Configuration

string
required
Secret key for JWT token generation. Generate a secure random string.Security: Never commit this to version control!
string
JWT algorithm. Default: "HS256"
integer
Access token expiration in minutes. Default: 30
integer
Refresh token expiration in days. Default: 7
Code Reference: app/auth/jwt_auth.py

Twilio Configuration (Loan Recovery)

Twilio integration enables SMS and voice communication for loan recovery workflows.
boolean
Enable Twilio integration. Default: false
string
Twilio Account SID. Get from https://console.twilio.com/
string
Twilio Auth Token. Get from https://console.twilio.com/Security: Never commit this to version control!
string
Twilio phone number in E.164 format (e.g., +1234567890).Purchase from https://console.twilio.com/us1/develop/phone-numbers/manage/search
boolean
Enable SMS functionality. Default: true
boolean
Enable voice call functionality. Default: true
string
Webhook URL for Twilio status callbacks.Format: https://your-domain.com/api/twilio/webhook/statusFor local development with tunneling: https://your-tunnel-url.loca.lt/api/twilio/webhook/status
Setup Guide: See Twilio Setup Guide Code Reference: app/services/twilio_service.py, app/services/loan_recovery_service.py

DigiSigner Configuration (Digital Signatures)

string
DigiSigner API key. Get from https://www.digisigner.com/
string
DigiSigner API base URL. Default: https://api.digisigner.com/v1
string
Webhook secret for verifying DigiSigner webhook signatures (optional but recommended for production)
Setup Guide: See DigiSigner Setup Guide Code Reference: app/services/signature_service.py

Companies House API Configuration (UK Regulatory Filings)

string
Companies House API key. Free registration at https://developer.company-information.service.gov.uk/Required for automated UK charge filings (MR01)
Code Reference: app/services/filing_service.py

Blockchain & Smart Contract Configuration

CreditNexus uses Base network (Coinbase Layer 2) for blockchain operations.

Network Configuration

boolean
Enable x402 payment protocol. Default: true
string
x402 facilitator URL. Default: https://facilitator.x402.org
string
Blockchain network. Default: "base"
string
RPC URL for Base network:Mainnet: https://mainnet.base.orgSepolia Testnet: https://sepolia.base.org (recommended for development)Local Hardhat: http://127.0.0.1:8545
string
Token symbol. Default: "USDC"
string
USDC token address on Base network.Base Mainnet: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913Base Sepolia: Check Base Sepolia documentation for testnet USDC address

Smart Contract Configuration

string
SecuritizationNotarization contract address (Base network).Leave empty to auto-deploy on first use (requires BLOCKCHAIN_AUTO_DEPLOY=true)
string
SecuritizationToken (ERC-721) contract address (Base network).Leave empty to auto-deploy on first use (requires BLOCKCHAIN_AUTO_DEPLOY=true)
string
SecuritizationPaymentRouter contract address (Base network).Leave empty to auto-deploy on first use (requires BLOCKCHAIN_AUTO_DEPLOY=true)
string
Private key for contract deployment (optional, auto-generated in dev if not provided).Not required for local Hardhat: use npm run deploy:local or npm run node + npm run deploy:localhost in contracts/ (see contracts/README.md).Security: Never commit private keys to version control!Format: 0x... (64 hex characters, no 0x prefix in .env)
boolean
Auto-deploy contracts if addresses not in config.Default: true (development), false (production - manually deploy contracts)
boolean
Auto-generate demo wallet addresses for users without wallets.Default: true (useful for development and demos)
Setup Guides: MetaMask Setup · Hardhat Local Blockchain (organisations) Code Reference: app/core/config.py (lines 143-172), contracts/hardhat.config.js

Enhanced Satellite Verification & Green Finance

boolean
Enable enhanced satellite features (green finance metrics, OSM, air quality). Default: true

OpenStreetMap Configuration

string
Street map API provider. Only "openstreetmap" supported.
string
OpenStreetMap Overpass API URL. Default: https://overpass-api.de/api/interpreter
boolean
Enable OSM data caching. Default: true
integer
OSM cache TTL in hours. Default: 24

Air Quality Configuration

boolean
Enable air quality monitoring. Default: true
string
Air quality API provider. Default: "openaq"
string
Air quality API key (not required for OpenAQ free tier)
boolean
Enable air quality data caching. Default: true
integer
Air quality cache TTL in hours. Default: 24

Vehicle Detection (Selective - High Cost)

boolean
Enable vehicle detection (default: disabled, enable for high-value cases only). Default: false
string
Path to vehicle detection model. Default: ./models/vehicle_detector.pt
float
Only process if transaction amount exceeds this value. Default: 1000000.0 ($1M)
boolean
Use high-resolution imagery for vehicle detection. Default: true

Pollution Monitoring

boolean
Enable pollution monitoring. Default: true
boolean
Enable methane monitoring. Default: true
boolean
Use Sentinel-5P for methane detection (free, coarse resolution). Default: true

Sustainability Scoring

boolean
Enable sustainability scoring. Default: true
float
NDVI component weight (must sum to 1.0). Default: 0.25
float
Air Quality Index weight. Default: 0.25
float
Activity weight. Default: 0.20
float
Green infrastructure weight. Default: 0.15
float
Pollution weight. Default: 0.15
Code Reference: app/agents/verifier.py, app/services/green_finance_service.py

LangChain Configuration

float
Temperature for filing requirement evaluation chains (0.0 = deterministic). Default: 0.0
float
Temperature for signature request generation chains (0.0 = deterministic). Default: 0.0
integer
Maximum retry attempts for filing chains. Default: 3
integer
Maximum retry attempts for signature chains. Default: 3

Audio & Image Processing Configuration

Speech-to-Text (STT)

string
Gradio Space URL for speech-to-text. Default: https://nvidia-canary-1b-v2.hf.space
string
Source language code. Default: "en"
string
Target language code. Default: "en"

Optical Character Recognition (OCR)

string
Gradio Space URL for OCR. Default: https://prithivmlmods-multimodal-ocr3.hf.space

ChromaDB Configuration

string
Directory for ChromaDB persistence. Default: ./chroma_db
string
Optional: Directory to load documents into ChromaDB on startup
Code Reference: app/agents/vector_store.py

Data Cache Configuration

CreditNexus uses unified caching for market data, tools, and external APIs. All TTL values are in seconds.
integer
Daily OHLCV bars cache TTL. Default: 604800 (7 days)
integer
Hourly OHLCV bars cache TTL. Default: 86400 (1 day)
integer
15-minute OHLCV bars cache TTL. Default: 14400 (4 hours)
integer
Ticker snapshot cache TTL (e.g., Polygon). Default: 90 (90 seconds)
integer
Fundamental data cache TTL (e.g., Alpha Vantage). Default: 86400 (24 hours)
integer
News cache TTL (e.g., Tickertick). Default: 1800 (30 minutes)
Web search results cache TTL. Default: 3600 (1 hour)
integer
Alpaca/trading quotes cache TTL. Default: 60 (1 minute)
integer
Backtest results cache TTL. Default: 86400 (24 hours)
Code Reference: app/core/data_cache.py

Stock Prediction Configuration

Stock prediction provides daily, hourly, and 15-minute forecasts using Chronos models or technical strategies.
boolean
Enable stock prediction APIs (daily, hourly, 15min, backtest, recommend-order, models, market-status). Default: falseIf false, all prediction endpoints return 403.
integer
Default lookback bars for daily predictions. Default: 252
integer
Default lookback bars for hourly predictions. Default: 504
integer
Default lookback bars for 15-minute predictions. Default: 96
boolean
Run Chronos locally with chronos-bolt (True) or use Modal chronos_inference (False). Default: falseLocal: Requires pip install chronos-bolt torch
string
Chronos model identifier. Default: "amazon/chronos-t5-small"Options: "amazon/chronos-t5-small", "amazon/chronos-t5-base"Selectable in Predictions tab and via model_id query parameter.
string
Device for Chronos: "cpu", "cuda", "cuda:0". Default: "cpu"Used by Modal and when running locally.
string
Modal app name for Chronos. Default: "creditnexus-stock-prediction"
string
Modal token ID for server-side client (optional)
string
Modal token secret
boolean
Use GPU (T4) for Chronos inference on Modal. Default: falseNote: Set MODAL_USE_GPU=1 when running modal run or modal deploy (environment variable at run/deploy time).
Setup Guide: See Stock Prediction Setup Guide Code Reference: app/services/stock_prediction_service.py, app/services/chronos_model_manager.py

Alpaca Trading & Market Data Configuration

Alpaca is used for trading (place/cancel orders, portfolio) and historical OHLCV for stock prediction when enabled.
string
Trading API base URL. Default: "https://paper-api.alpaca.markets"Paper: https://paper-api.alpaca.markets Live: https://api.alpaca.markets
string
Alpaca API key. Get from https://alpaca.markets/
string
Alpaca API secret. Get from https://alpaca.markets/
boolean
Use Alpaca for historical bars in stock prediction and backtesting. Default: falseWhen false, MarketDataService uses yahooquery only.
Setup Guide: See Alpaca Trading Setup Guide Code Reference: app/services/trading_api_service.py, app/services/market_data_service.py

Polymarket Configuration

Polymarket-style prediction markets for Structured Financial Products (SFPs).
boolean
Enable Polymarket features. Default: false
string
Polymarket CLOB API URL. Default: "https://clob.polymarket.com"
string
Optional CLOB API key
string
Blockchain network. Default: "polygon"
string
Gamma API URL. Default: "https://gamma-api.polymarket.com"
string
Data API URL. Default: "https://data-api.polymarket.com"
boolean
Enable market surveillance and alerts. Default: false
boolean
Publish markets to external Polymarket. Default: false
Setup Guide: See Polymarket Surveillance Signals Guide Code Reference: app/services/polymarket_service.py, app/api/polymarket_routes.py

Cross-Chain Configuration

Cross-chain support allows bridging and SFP outcome token minting on L2s (e.g., Base, Polygon).
boolean
Enable cross-chain bridge and outcome token minting. Default: false
string
Bridge API base URL for cross-chain transfers (Polymarket bridge or custom relay)
integer
Chain ID for outcome tokens (e.g., Base=8453, Polygon=137)
string
ERC-1155 SFP outcome token contract address on OUTCOME_TOKEN_CHAIN_ID
Setup Guide: See Polymarket Cross-Chain Setup Guide Code Reference: app/services/bridge_service.py, app/api/cross_chain_routes.py

RevenueCat Configuration

RevenueCat integration enables entitlement checks and subscription upgrades (via x402 on web or in-app purchase on mobile). The server uses the Secret API key (sk_…) for REST API: subscriber lookup and promotional entitlement grants.
boolean
Enable RevenueCat integration. Default: falseEnables entitlement checks (GET /api/subscriptions/entitlement) and post-x402 promotional grants. When true, 402 responses can include revenuecat_available and revenuecat_endpoint for mobile purchase path.
string
RevenueCat secret API key (sk_…) for server-side REST API. Required when REVENUECAT_ENABLED=true. Get from RevenueCat Dashboard → Project → API keys. Never expose in client or version control.
string
Entitlement identifier for Pro tier. Use the exact identifier from RevenueCat (e.g. entlfa0ee126b6 for REST API). Must match Dashboard → Entitlements. Default: "pro"
float
Amount in USD for subscription upgrade via x402 (POST /api/subscriptions/upgrade). Default: 9.99
Product IDs used by POST /api/subscriptions/revenuecat/purchase: subscription_upgrade, org_admin, mobile_app. Create matching products in RevenueCat and attach them to your entitlement(s). See RevenueCat Setup. Setup Guide: RevenueCat Setup for the Server Code Reference: app/services/revenuecat_service.py, app/api/subscription_routes.py, app/services/payment_router_service.py

Rolling Credits & CreditToken Configuration

Rolling credits are subscription-based credits that can optionally be registered on-chain via the CreditToken ERC-721 contract. Credits are treated as pennies (1 USD top-up adds CREDITS_PENNIES_PER_USD credits, default 100).
integer
Credits added per 1 USD on credit top-up (1 credit = 1 penny when 100). Default: 100
string
CreditToken (ERC-721) contract address. Default: ""If empty, credits are still generated in DB but not registered on-chain.
Setup Guide: See Rolling Credits Setup Guide Code Reference: app/services/rolling_credits_service.py, contracts/contracts/CreditToken.sol

Demo Data Configuration

boolean
Enable demo data generation. Default: true
integer
Number of demo deals to generate. Default: 12
string
Comma-separated list of deal types. Default: loan_application,refinancing,restructuring
string
Storage path for demo data. Default: storage/deals/demo
boolean
Enable demo data caching. Default: true
integer
Cache TTL in seconds. Default: 86400 (24 hours)
string
Cache file path (optional)

Seeding Configuration

boolean
Seed permission definitions and role mappings on startup. Default: false
boolean
Force update existing permissions (use with caution). Default: false
boolean
Seed demo users on startup. Default: false
boolean
Force update existing demo users (use with caution). Default: false
boolean
Seed auditor role. Default: false
boolean
Seed banker role. Default: false
boolean
Seed law officer role. Default: false
boolean
Seed accountant role. Default: false
boolean
Seed applicant role. Default: false

Remote API Configuration

boolean
Enable remote API for SSL-enabled verification links. Default: false
string
Path to SSL certificate file for remote API
string
Path to SSL private key file for remote API
Code Reference: app/api/remote_routes.py

File Storage Configuration

string
Base directory for file storage. Default: ./storage
string
Directory for deal documents. Default: storage/deals
string
Directory for templates. Default: storage/templates
Code Reference: app/services/file_storage_service.py

Configuration Examples

Minimal Development Setup

Production Setup with All Features

Local AI Setup (HuggingFace)


Security Best Practices

  1. Never commit secrets to version control
    • Use .env file (already in .gitignore)
    • Use SecretStr type in Pydantic settings
    • Rotate keys regularly
  2. Use SSL/TLS in production
    • Enable DB_SSL_REQUIRED=true for database
    • Configure SSL certificates for remote API
    • Use HTTPS for all webhook URLs
  3. Environment-specific configuration
    • Development: Use testnet for blockchain, local models
    • Production: Use mainnet, require SSL, disable auto-deployment
  4. Access control
    • Use strong JWT secret keys
    • Set appropriate token expiration times
    • Enable policy engine for compliance

Troubleshooting

LLM Provider Issues

Issue: OpenAI API errors
  • Verify OPENAI_API_KEY is set correctly
  • Check API rate limits and billing
  • Review network connectivity
Issue: HuggingFace local models not loading
  • Ensure sufficient RAM/VRAM
  • Check EMBEDDINGS_DEVICE setting
  • Verify model path is correct

Database Connection Issues

Issue: Cannot connect to PostgreSQL
  • Verify DATABASE_URL format
  • Check PostgreSQL is running
  • Verify user permissions
Issue: SSL connection errors
  • Verify SSL certificates are valid
  • Check DB_SSL_MODE setting
  • Ensure certificates are readable

Blockchain Issues

Issue: Cannot connect to Base network
  • Verify X402_NETWORK_RPC_URL is correct
  • Check network connectivity
  • For testnet, use https://sepolia.base.org
Issue: Contract deployment fails
  • Local Hardhat: use npm run deploy:local or npm run node + npm run deploy:localhost in contracts/ (no private key needed). Set X402_NETWORK_RPC_URL=http://127.0.0.1:8545 and the printed contract addresses.
  • Base / Base Sepolia: verify PRIVATE_KEY or BLOCKCHAIN_DEPLOYER_PRIVATE_KEY is set in project root .env
  • Check account has sufficient ETH for gas
  • Verify RPC URL is accessible

Additional Resources


Configuration File: app/core/config.py
Last Updated: 2026-01-14