The ObjAiMcpOpenrouter class routes prompts through
OpenRouter, an OpenAI-compatible
aggregator that exposes hundreds of hosted models behind a
single endpoint. Several models are tagged :free and run
at no cost (with rate limits). Inherits from
ObjAiMcpBase and reuses the official openai Python
client with a custom base_url.
def __init__(
self,
db: object = 0,
api_key: str = "",
model: str = "meta-llama/llama-3.3-70b-instruct:free",
) -> None
db: database connection.api_key: OpenRouter API key (sk-or-...).model: OpenRouter model id, vendor/name[:variant].In config.yaml (or any package override):
ai_mcp_openrouter:
api_key: sk-or-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
referer: https://www.technocore.co.za # optional
title: Axion # optional
referer and title map to the OpenRouter HTTP-Referer
and X-Title headers — both optional but recommended so
requests are attributed correctly on the dashboard.
from ObjAI import ObjAI
ai = ObjAI(
db=0,
model="mcp:openrouter:"
"meta-llama/llama-3.3-70b-instruct:free",
)
print(ai.prompt(
"You are a credit-risk analyst.",
"Summarise the outcome distribution.",
))
To use OpenRouter for the sim email AI analysis, set
ai.sim_analysis_model in config.yaml:
ai:
sim_analysis_model: |
mcp:openrouter:meta-llama/llama-3.3-70b-instruct:free
Look for the :free suffix on the model id. Examples
(availability changes — check the OpenRouter model list):
meta-llama/llama-3.3-70b-instruct:freedeepseek/deepseek-chat-v3-0324:freeqwen/qwen3-235b-a22b:freegoogle/gemini-2.0-flash-exp:freeFree routes carry per-key rate limits and may queue under
load; for higher throughput, fall back to a paid route.