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):Your OpenAI API key. Get from https://platform.openai.com/api-keys
LLM provider:
"openai", "vllm", or "huggingface". Default: "openai"Model identifier. OpenAI:
"gpt-4o", "gpt-4o-mini", "gpt-3.5-turbo". Default: "gpt-4o"Temperature for generation (0.0 = deterministic, 1.0 = creative). Default:
0.0app/core/llm_client.py - get_chat_model()
vLLM Configuration
For self-hosted vLLM servers:Base URL for your vLLM server (e.g.,
"http://localhost:8000")Optional API key if your vLLM server requires authentication
HuggingFace Configuration
HuggingFace supports both inference endpoints (API-based) and local models.HuggingFace API token. Get from https://huggingface.co/settings/tokens
Custom base URL. Default:
https://api-inference.huggingface.co/v1For Inference Providers router: https://router.huggingface.co/{provider}/v3/openaiInference 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"
"novita" (preferred provider)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: falsemeta-llama/Llama-3.1-8B-Instructmicrosoft/Phi-3.5-mini-instructdeepseek-ai/DeepSeek-V3.2-Exp
app/core/llm_client.py - get_chat_model()
Embeddings Configuration
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"Embeddings provider:
"openai", "huggingface", or leave empty to use LLM_PROVIDER.Default: "huggingface"Use local embeddings model instead of API (HuggingFace only). Default:
falseDevice for local embeddings:
"cpu", "cuda", "cuda:0", or "auto". Default: "cpu"Additional model kwargs as JSON string. Examples:
'{"device_map":"auto"}''{"trust_remote_code":true}''{"device":"cuda","model_kwargs":{"torch_dtype":"float16"}}'
app/core/llm_client.py - get_embeddings_model()
SentinelHub Configuration
SentinelHub provides satellite imagery for verification workflows.SentinelHub OAuth client ID. Get from https://www.sentinel-hub.com/
SentinelHub OAuth client secret. Get from https://www.sentinel-hub.com/
app/agents/verifier.py
Policy Engine Configuration
Enable policy engine for real-time compliance enforcement. Default:
trueDirectory containing policy rule YAML files. Default:
app/policiesFile pattern for policy rules. Default:
*.yamlPolicy engine vendor (optional). Default:
"" (uses default engine)Auto-reload policy rules on file changes (development only). Default:
falseapp/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.Polygon.io API key for market data. Get from https://polygon.io/Required for: Market data fetching, ticker snapshots, historical data
Alpha Vantage API key for fundamental data. Get from https://www.alphavantage.co/support/#api-keyRequired for: Company fundamentals, financial statements, earnings data
Tavily API key for news/search. Get from https://tavily.com/Optional: Falls back to WebSearchService if not configured
Tickertick API key for financial news.Optional: Service may not be publicly available. Falls back to web_search tool or Tavily.
LLM model for reasoning tasks (supervisor, planner, analyst). Default:
"gpt-4o"LLM model for basic tasks (researcher, reporter, market). Default:
"gpt-4o-mini"LLM model for economic analysis tasks. Default:
"gpt-4o-mini"LLM model for coding/calculation tasks. Default:
"gpt-4o"Budget level for LangAlpha agents:
"low", "medium", or "high". Default: "medium"low: Uses cheaper models, fewer iterationsmedium: Balanced cost and qualityhigh: Uses premium models, more thorough analysis
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.Serper API key for Google search. Get from https://serper.dev/Optional: Falls back to WebSearchService if not configured
Web search rate limit (requests per hour). Default:
360Enable caching for web search results. Default:
trueWeb search cache TTL in hours. Default:
24app/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.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)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)
Device for local reranking:
"cpu", "cuda", "cuda:0", etc. Default: "cpu"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
Remote reranking API key (only needed if using remote reranking)
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
PostgreSQL connection string:Format:
postgresql://user:password@localhost:5432/creditnexusFor SQLite (development fallback): sqlite:///./creditnexus.dbEnable database connection. Default:
trueDatabase SSL/TLS Configuration
For production, SSL/TLS encryption is required:Require SSL/TLS for database connections. Default:
false (development), true (production)SSL mode:
"prefer", "require", "verify-ca", "verify-full". Default: "prefer"Path to SSL client certificate file (optional)
Path to SSL client key file (optional)
Path to SSL CA certificate file (required for
verify-ca and verify-full modes)Automatically generate self-signed certificates for development. Default:
falseAuto-generate CA certificate. Default:
true (when DB_SSL_AUTO_GENERATE=true)Auto-generate client certificate for mutual TLS. Default:
falseCertificate directory for auto-generated certificates. Default:
"./ssl_certs/db"Certificate validity period in days. Default:
365app/core/config.py, app/db/ssl_config.py
Authentication Configuration
Secret key for JWT token generation. Generate a secure random string.Security: Never commit this to version control!
JWT algorithm. Default:
"HS256"Access token expiration in minutes. Default:
30Refresh token expiration in days. Default:
7app/auth/jwt_auth.py
Twilio Configuration (Loan Recovery)
Twilio integration enables SMS and voice communication for loan recovery workflows.Enable Twilio integration. Default:
falseTwilio Account SID. Get from https://console.twilio.com/
Twilio Auth Token. Get from https://console.twilio.com/Security: Never commit this to version control!
Twilio phone number in E.164 format (e.g.,
+1234567890).Purchase from https://console.twilio.com/us1/develop/phone-numbers/manage/searchEnable SMS functionality. Default:
trueEnable voice call functionality. Default:
trueWebhook 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/statusapp/services/twilio_service.py, app/services/loan_recovery_service.py
DigiSigner Configuration (Digital Signatures)
DigiSigner API key. Get from https://www.digisigner.com/
DigiSigner API base URL. Default:
https://api.digisigner.com/v1Webhook secret for verifying DigiSigner webhook signatures (optional but recommended for production)
app/services/signature_service.py
Companies House API Configuration (UK Regulatory Filings)
Companies House API key. Free registration at https://developer.company-information.service.gov.uk/Required for automated UK charge filings (MR01)
app/services/filing_service.py
Blockchain & Smart Contract Configuration
CreditNexus uses Base network (Coinbase Layer 2) for blockchain operations.Network Configuration
Enable x402 payment protocol. Default:
truex402 facilitator URL. Default:
https://facilitator.x402.orgBlockchain network. Default:
"base"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:8545Token symbol. Default:
"USDC"USDC token address on Base network.Base Mainnet:
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913Base Sepolia: Check Base Sepolia documentation for testnet USDC addressSmart Contract Configuration
SecuritizationNotarization contract address (Base network).Leave empty to auto-deploy on first use (requires
BLOCKCHAIN_AUTO_DEPLOY=true)SecuritizationToken (ERC-721) contract address (Base network).Leave empty to auto-deploy on first use (requires
BLOCKCHAIN_AUTO_DEPLOY=true)SecuritizationPaymentRouter contract address (Base network).Leave empty to auto-deploy on first use (requires
BLOCKCHAIN_AUTO_DEPLOY=true)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)Auto-deploy contracts if addresses not in config.Default:
true (development), false (production - manually deploy contracts)Auto-generate demo wallet addresses for users without wallets.Default:
true (useful for development and demos)app/core/config.py (lines 143-172), contracts/hardhat.config.js
Enhanced Satellite Verification & Green Finance
Enable enhanced satellite features (green finance metrics, OSM, air quality). Default:
trueOpenStreetMap Configuration
Street map API provider. Only
"openstreetmap" supported.OpenStreetMap Overpass API URL. Default:
https://overpass-api.de/api/interpreterEnable OSM data caching. Default:
trueOSM cache TTL in hours. Default:
24Air Quality Configuration
Enable air quality monitoring. Default:
trueAir quality API provider. Default:
"openaq"Air quality API key (not required for OpenAQ free tier)
Enable air quality data caching. Default:
trueAir quality cache TTL in hours. Default:
24Vehicle Detection (Selective - High Cost)
Enable vehicle detection (default: disabled, enable for high-value cases only). Default:
falsePath to vehicle detection model. Default:
./models/vehicle_detector.ptOnly process if transaction amount exceeds this value. Default:
1000000.0 ($1M)Use high-resolution imagery for vehicle detection. Default:
truePollution Monitoring
Enable pollution monitoring. Default:
trueEnable methane monitoring. Default:
trueUse Sentinel-5P for methane detection (free, coarse resolution). Default:
trueSustainability Scoring
Enable sustainability scoring. Default:
trueNDVI component weight (must sum to 1.0). Default:
0.25Air Quality Index weight. Default:
0.25Activity weight. Default:
0.20Green infrastructure weight. Default:
0.15Pollution weight. Default:
0.15app/agents/verifier.py, app/services/green_finance_service.py
LangChain Configuration
Temperature for filing requirement evaluation chains (0.0 = deterministic). Default:
0.0Temperature for signature request generation chains (0.0 = deterministic). Default:
0.0Maximum retry attempts for filing chains. Default:
3Maximum retry attempts for signature chains. Default:
3Audio & Image Processing Configuration
Speech-to-Text (STT)
Gradio Space URL for speech-to-text. Default:
https://nvidia-canary-1b-v2.hf.spaceSource language code. Default:
"en"Target language code. Default:
"en"Optical Character Recognition (OCR)
Gradio Space URL for OCR. Default:
https://prithivmlmods-multimodal-ocr3.hf.spaceChromaDB Configuration
Directory for ChromaDB persistence. Default:
./chroma_dbOptional: Directory to load documents into ChromaDB on startup
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.Daily OHLCV bars cache TTL. Default:
604800 (7 days)Hourly OHLCV bars cache TTL. Default:
86400 (1 day)15-minute OHLCV bars cache TTL. Default:
14400 (4 hours)Ticker snapshot cache TTL (e.g., Polygon). Default:
90 (90 seconds)Fundamental data cache TTL (e.g., Alpha Vantage). Default:
86400 (24 hours)News cache TTL (e.g., Tickertick). Default:
1800 (30 minutes)Web search results cache TTL. Default:
3600 (1 hour)Alpaca/trading quotes cache TTL. Default:
60 (1 minute)Backtest results cache TTL. Default:
86400 (24 hours)app/core/data_cache.py
Stock Prediction Configuration
Stock prediction provides daily, hourly, and 15-minute forecasts using Chronos models or technical strategies.Enable stock prediction APIs (daily, hourly, 15min, backtest, recommend-order, models, market-status). Default:
falseIf false, all prediction endpoints return 403.Default lookback bars for daily predictions. Default:
252Default lookback bars for hourly predictions. Default:
504Default lookback bars for 15-minute predictions. Default:
96Run Chronos locally with
chronos-bolt (True) or use Modal chronos_inference (False). Default: falseLocal: Requires pip install chronos-bolt torchChronos 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.Device for Chronos:
"cpu", "cuda", "cuda:0". Default: "cpu"Used by Modal and when running locally.Modal app name for Chronos. Default:
"creditnexus-stock-prediction"Modal token ID for server-side client (optional)
Modal token secret
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).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.Trading API base URL. Default:
"https://paper-api.alpaca.markets"Paper: https://paper-api.alpaca.markets
Live: https://api.alpaca.marketsAlpaca API key. Get from https://alpaca.markets/
Alpaca API secret. Get from https://alpaca.markets/
Use Alpaca for historical bars in stock prediction and backtesting. Default:
falseWhen false, MarketDataService uses yahooquery only.app/services/trading_api_service.py, app/services/market_data_service.py
Polymarket Configuration
Polymarket-style prediction markets for Structured Financial Products (SFPs).Enable Polymarket features. Default:
falsePolymarket CLOB API URL. Default:
"https://clob.polymarket.com"Optional CLOB API key
Blockchain network. Default:
"polygon"Gamma API URL. Default:
"https://gamma-api.polymarket.com"Data API URL. Default:
"https://data-api.polymarket.com"Enable market surveillance and alerts. Default:
falsePublish markets to external Polymarket. Default:
falseapp/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).Enable cross-chain bridge and outcome token minting. Default:
falseBridge API base URL for cross-chain transfers (Polymarket bridge or custom relay)
Chain ID for outcome tokens (e.g., Base=8453, Polygon=137)
ERC-1155 SFP outcome token contract address on
OUTCOME_TOKEN_CHAIN_IDapp/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.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.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.Entitlement identifier for Pro tier. Use the exact identifier from RevenueCat (e.g.
entlfa0ee126b6 for REST API). Must match Dashboard → Entitlements. Default: "pro"Amount in USD for subscription upgrade via x402 (
POST /api/subscriptions/upgrade). Default: 9.99POST /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 addsCREDITS_PENNIES_PER_USD credits, default 100).
Credits added per 1 USD on credit top-up (1 credit = 1 penny when 100). Default:
100CreditToken (ERC-721) contract address. Default:
""If empty, credits are still generated in DB but not registered on-chain.app/services/rolling_credits_service.py, contracts/contracts/CreditToken.sol
Demo Data Configuration
Enable demo data generation. Default:
trueNumber of demo deals to generate. Default:
12Comma-separated list of deal types. Default:
loan_application,refinancing,restructuringStorage path for demo data. Default:
storage/deals/demoEnable demo data caching. Default:
trueCache TTL in seconds. Default:
86400 (24 hours)Cache file path (optional)
Seeding Configuration
Seed permission definitions and role mappings on startup. Default:
falseForce update existing permissions (use with caution). Default:
falseSeed demo users on startup. Default:
falseForce update existing demo users (use with caution). Default:
falseSeed auditor role. Default:
falseSeed banker role. Default:
falseSeed law officer role. Default:
falseSeed accountant role. Default:
falseSeed applicant role. Default:
falseRemote API Configuration
Enable remote API for SSL-enabled verification links. Default:
falsePath to SSL certificate file for remote API
Path to SSL private key file for remote API
app/api/remote_routes.py
File Storage Configuration
Base directory for file storage. Default:
./storageDirectory for deal documents. Default:
storage/dealsDirectory for templates. Default:
storage/templatesapp/services/file_storage_service.py
Configuration Examples
Minimal Development Setup
Production Setup with All Features
Local AI Setup (HuggingFace)
Security Best Practices
-
Never commit secrets to version control
- Use
.envfile (already in.gitignore) - Use
SecretStrtype in Pydantic settings - Rotate keys regularly
- Use
-
Use SSL/TLS in production
- Enable
DB_SSL_REQUIRED=truefor database - Configure SSL certificates for remote API
- Use HTTPS for all webhook URLs
- Enable
-
Environment-specific configuration
- Development: Use testnet for blockchain, local models
- Production: Use mainnet, require SSL, disable auto-deployment
-
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_KEYis set correctly - Check API rate limits and billing
- Review network connectivity
- Ensure sufficient RAM/VRAM
- Check
EMBEDDINGS_DEVICEsetting - Verify model path is correct
Database Connection Issues
Issue: Cannot connect to PostgreSQL- Verify
DATABASE_URLformat - Check PostgreSQL is running
- Verify user permissions
- Verify SSL certificates are valid
- Check
DB_SSL_MODEsetting - Ensure certificates are readable
Blockchain Issues
Issue: Cannot connect to Base network- Verify
X402_NETWORK_RPC_URLis correct - Check network connectivity
- For testnet, use
https://sepolia.base.org
- Local Hardhat: use
npm run deploy:localornpm run node+npm run deploy:localhostincontracts/(no private key needed). SetX402_NETWORK_RPC_URL=http://127.0.0.1:8545and the printed contract addresses. - Base / Base Sepolia: verify
PRIVATE_KEYorBLOCKCHAIN_DEPLOYER_PRIVATE_KEYis set in project root.env - Check account has sufficient ETH for gas
- Verify RPC URL is accessible
Additional Resources
- Quick Start Guide
- Installation Guide
- Twilio Setup Guide
- DigiSigner Setup Guide
- MetaMask Setup Guide
- SentinelHub Setup Guide
- Security Documentation
Configuration File:
app/core/config.pyLast Updated: 2026-01-14