janus-scanner-pro / api_integration.py
hts-ai's picture
active tout les api en reel tu es un pro
1839043 verified
```python
"""
Janus Scanner Pro - OpenRouter API Integration
API Configuration and Model Integration Examples
"""
from openai import OpenAI
import json
# Configuration
API_KEY = "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"
BASE_URL = "https://openrouter.ai/api/v1"
# Initialize OpenRouter client
client = OpenAI(
base_url=BASE_URL,
api_key=API_KEY,
)
class JanusAPIIntegration:
"""Main class for Janus Scanner API integrations"""
def __init__(self):
self.client = client
self.base_headers = {
"HTTP-Referer": "https://janus-scanner-pro.com",
"X-Title": "Janus Scanner Pro"
}
def text_analysis(self, text, model="deepseek/deepseek-chat-v3.1:free"):
"""Analyze text for fraud detection patterns"""
messages = [
{
"role": "system",
"content": "You are a financial fraud detection expert. Analyze the provided text for suspicious patterns, anomalies, and potential fraud indicators."
},
{
"role": "user",
"content": f"Analyze this financial data for fraud patterns: {text}"
}
]
completion = self.client.chat.completions.create(
extra_headers=self.base_headers,
model=model,
messages=messages
)
return completion.choices[0].message.content
def document_analysis(self, text, model="google/gemma-3-27b-it:free"):
"""Advanced document analysis with vision capabilities"""
messages = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Analyze this financial document for compliance issues, suspicious transactions, and regulatory violations."
},
{
"type": "text",
"text": text
}
]
}
]
completion = self.client.chat.completions.create(
extra_headers=self.base_headers,
model=model,
messages=messages
)
return completion.choices[0].message.content
def risk_assessment(self, transaction_data, model="nousresearch/hermes-3-llama-3.1-405b:free"):
"""Generate risk assessment for financial transactions"""
messages = [
{
"role": "system",
"content": "You are a risk assessment expert. Analyze transaction data and provide detailed risk scores and recommendations."
},
{
"role": "user",
"content": f"Assess the risk level for these transactions and provide recommendations: {transaction_data}"
}
]
completion = self.client.chat.completions.create(
extra_headers=self.base_headers,
model=model,
messages=messages
)
return completion.choices[0].message.content
# Model configurations for different use cases
MODEL_CONFIGS = {
"text_analysis": {
"default": "deepseek/deepseek-chat-v3.1:free",
"fast": "meituan/longcat-flash-chat:free",
"high_capacity": "nousresearch/hermes-3-llama-3.1-405b:free"
},
"image_analysis": {
"default": "google/gemma-3-27b-it:free",
"specialized": "mistralai/mistral-small-3.2-24b-instruct:free"
},
"complex_reasoning": {
"default": "nousresearch/hermes-3-llama-3.1-405b:free"
}
}
def run_examples():
"""Run example API calls"""
# Example 1: Text Analysis with DeepSeek
print("=== Example 1: DeepSeek Text Analysis ===")
janus = JanusAPIIntegration()
sample_financial_text = """
Transaction Report:
- $15,000 cash withdrawal from account ending 1234
- Multiple $9,999 transactions within 1 hour
- International wire transfer to unknown entity
- Account balance: $0 after suspicious activities
"""
result1 = janus.text_analysis(sample_financial_text)
print("Analysis Result:", result1)
print()
# Example 2: Document Analysis with Gemma
print("=== Example 2: Gemma Document Analysis ===")
sample_document = """
Quarterly Report Q4 2024:
Revenue: $2,450,000
Expenses: $2,100,000
Unknown expenses: $350,000 (marked as 'miscellaneous')
Cash payments: $180,000 (cash only, no receipts)
Related party transactions: $120,000 to entity with same address
"""
result2 = janus.document_analysis(sample_document)
print("Document Analysis:", result2)
print()
# Example 3: Risk Assessment with Hermes
print("=== Example 3: Hermes Risk Assessment ===")
transaction_data = [
{"amount": 9999, "type": "withdrawal", "time": "23:45"},
{"amount": 9999, "type": "withdrawal", "time": "23:46"},
{"amount": 9999, "type": "withdrawal", "time": "23:47"},
{"amount": 15000, "type": "wire_transfer", "account": "unknown"},
{"amount": 5000, "type": "cash_deposit", "location": "different_city"}
]
result3 = janus.risk_assessment(json.dumps(transaction_data))
print("Risk Assessment:", result3)
print()
# Example 4: Fast Analysis with Longcat
print("=== Example 4: Longcat Fast Analysis ===")
messages = [
{
"role": "user",
"content": "Quickly identify the main fraud indicators in this data: Multiple round number transactions, cash payments, and international transfers"
}
]
completion = client.chat.completions.create(
extra_headers={
"HTTP-Referer": "https://janus-scanner-pro.com",
"X-Title": "Janus Scanner Pro"
},
model="meituan/longcat-flash-chat:free",
messages=messages
)
print("Fast Analysis:", completion.choices[0].message.content)
print()
# Example 5: Multi-step Analysis Workflow
print("=== Example 5: Multi-step Analysis ===")
def comprehensive_analysis(data):
# Step 1: Initial scan
scan_result = janus.text_analysis(data, "meituan/longcat-flash-chat:free")
# Step 2: Deep analysis if suspicious
if "suspicious" in scan_result.lower():
detailed_result = janus.risk_assessment(data, "nousresearch/hermes-3-llama-3.1-405b:free")
return {
"scan_result": scan_result,
"detailed_analysis": detailed_result,
"risk_level": "HIGH"
}
else:
return {
"scan_result": scan_result,
"risk_level": "LOW"
}
test_data = "Multiple $9999 transactions, cash deposits, international transfers"
workflow_result = comprehensive_analysis(test_data)
print("Comprehensive Analysis:", json.dumps(workflow_result, indent=2))
if __name__ == "__main__":
print("Janus Scanner Pro - OpenRouter API Integration")
print("=" * 50)
print("Available Models:")
for category, models in MODEL_CONFIGS.items():
print(f"\n{category.upper()}:")
for name, model in models.items():
print(f" {name}: {model}")
print("\n" + "=" * 50)
run_examples()
```
```