Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/RubenDarioGuerreroNeira/Ecosistema-IA-Colombia/llms.txt

Use this file to discover all available pages before exploring further.

Salud IA Bot is configured entirely through environment variables, validated at startup by a Joi schema defined in AppModule. This page documents every supported variable, explains how to obtain the required credentials, and shows the complete .env file format.

Environment Variables

Required

TELEGRAM_BOT_TOKEN
string
required
The Telegram Bot API token issued by @BotFather. This token authenticates the NestJS server against the Telegram Bot API and identifies which bot receives updates.Example: 1234567890:AABBCCDDEEFFaabbccddeeff-GGHHIIJJKKll
OPENROUTER_API_KEY
string
required
API key for OpenRouter.ai. Used by GenkitService to authenticate all chat completion requests to the LLaMA model. The key is passed directly to the OpenAI-compatible SDK with baseURL set to https://openrouter.ai/api/v1.Example: sk-or-v1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Optional

OPENROUTER_MODEL
string
default:"nvidia/nemotron-3-super-120b-a12b:free"
The OpenRouter model identifier used for all AI completions. Any model available on OpenRouter can be substituted here — the only requirement is compatibility with the OpenAI Chat Completions API format.Default: nvidia/nemotron-3-super-120b-a12b:freeExample alternatives:
  • meta-llama/Meta-Llama-3.1-70B-Instruct — Meta LLaMA 3.1 70B, high-quality responses (paid)
  • meta-llama/Meta-Llama-3.1-8B-Instruct — faster, lower cost, slightly less capable
PORT
number
default:"3000"
The HTTP port on which the NestJS server listens. Useful when deploying to a platform (Render, Railway, Fly.io) that injects a PORT environment variable automatically.Default: 3000
TELEGRAM_PROXY_URL
string
An HTTP proxy URL used to route all Telegram API calls through an intermediate proxy. Useful on hosting providers where outbound connections to api.telegram.org are blocked or restricted. The proxy is applied via https-proxy-agent in the TelegrafModule factory.Format: http://user:password@host:portExample: http://myuser:mypassword@proxy.example.com:8080
TELEGRAM_API_TIMEOUT
number
default:"30000"
Timeout in milliseconds for Telegram API calls. Increase this value if you are experiencing timeout errors on slow networks or when the bot sends large batches of fragmented messages.Default: 30000 (30 seconds)Example: 60000 (60 seconds, as suggested in .env.example)
OPENROUTER_BASE_URL
string
default:"https://openrouter.ai/api/v1"
The base URL for the OpenRouter API, validated by Joi at startup. Note that GenkitService currently hardcodes https://openrouter.ai/api/v1 directly and does not read this variable at runtime — override this only if you modify the service to consume it from ConfigService.Default: https://openrouter.ai/api/v1

Legacy Variables

The .env.example file in the repository contains GOOGLE_GENAI_API_KEY. This variable is a legacy artifact from an earlier Gemini-based implementation and is not present in the Joi validation schema. It has no effect on the running application and can be safely ignored or removed from your .env file. The application uses OPENROUTER_API_KEY exclusively for all AI calls.

Joi Validation

The app uses Joi to validate all environment variables at startup via NestJS ConfigModule. If a required variable (TELEGRAM_BOT_TOKEN or OPENROUTER_API_KEY) is missing or empty, the process will exit immediately with a clear validation error message — it will never start in a misconfigured state. Optional variables with defaults are automatically populated by Joi, so you do not need to specify them in .env unless you want non-default values.
The validation schema (from src/app.module.ts) is:
Joi.object({
  TELEGRAM_BOT_TOKEN: Joi.string().required(),
  OPENROUTER_API_KEY: Joi.string().required(),
  OPENROUTER_MODEL: Joi.string().default('nvidia/nemotron-3-super-120b-a12b:free'),
  OPENROUTER_BASE_URL: Joi.string().default('https://openrouter.ai/api/v1'),
  PORT: Joi.number().default(3000),
  TELEGRAM_PROXY_URL: Joi.string().optional().allow(''),
  TELEGRAM_API_TIMEOUT: Joi.number().default(30000),
})

Complete .env Example

# ── Required ──────────────────────────────────────────────────────
TELEGRAM_BOT_TOKEN=1234567890:AABBCCDDEEFFaabbccddeeff
OPENROUTER_API_KEY=sk-or-v1-...

# ── Optional (shown with defaults) ───────────────────────────────
OPENROUTER_MODEL=nvidia/nemotron-3-super-120b-a12b:free
PORT=3000

# ── Optional proxy (uncomment if needed) ─────────────────────────
# TELEGRAM_PROXY_URL=http://user:password@host:port
# TELEGRAM_API_TIMEOUT=60000

Getting Your Credentials

Telegram Bot Token

1

Open Telegram and find BotFather

Open the Telegram app on any device. In the search bar, type @BotFather and open the official verified account (blue checkmark).
2

Create a new bot

Send the command /newbot. BotFather will prompt you for:
  • A display name for your bot (e.g., Salud IA Colombia)
  • A username ending in bot (e.g., saludiacolombia_bot)
3

Copy your token

After confirming the username, BotFather replies with a message containing your bot token in the format 1234567890:ABCDEF.... Copy this value and set it as TELEGRAM_BOT_TOKEN in your .env file.
Your bot token grants full control over the bot. Never commit it to version control or expose it in client-side code. Use environment variables or a secrets manager at all times.

OpenRouter API Key

1

Sign up at OpenRouter

Go to openrouter.ai and create a free account. OpenRouter provides access to dozens of LLM providers, including Meta LLaMA 3.1, under a single unified API.
2

Navigate to API Keys

Once logged in, open the Keys section from the top navigation or your account dashboard.
3

Create a new key

Click Create Key, give it a descriptive name (e.g., salud-ia-bot-local), and copy the generated key immediately — it will not be shown again in full.
4

Add credits (if needed)

The default model (nvidia/nemotron-3-super-120b-a12b:free) is available on OpenRouter’s free tier at no cost. To use a paid model such as meta-llama/Meta-Llama-3.1-70B-Instruct, add credits from the Credits section of your OpenRouter dashboard.

Retry and Fault Tolerance

GenkitService implements automatic retry logic for transient OpenRouter errors. On HTTP 429 (rate limit) or 503 (service unavailable) responses, the service retries up to 3 times with exponential backoff (1 s, 2 s, 4 s). If all retries are exhausted, the error is surfaced to the caller and logged.
// From src/bot/genkit.service.ts
const MAX_RETRIES = 3;
// Retries on: error.status === 429 || error.status === 503
// Backoff: Math.pow(2, attempt) * 1000  →  1s, 2s, 4s
No additional configuration is required to enable this behavior — it is active by default for all AI calls.

Build docs developers (and LLMs) love