AgentOS API Configuration
AgentOS API Configuration
The AgentOS configuration service is the foundational layer connecting myProp to the AgentOS (letmc.com) API. It resolves connection credentials and deployment context from environment variables, validates them, and exposes a simple interface for all server-side API code.
Server-side only. This module reads
process.envdirectly and must not be imported from client components or any code that runs in the browser.
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
LETMC_API_KEY | ✅ Yes | — | API key for authenticating requests to the AgentOS API |
LETMC_API_BASE_URL | No | https://live-api.letmc.com | Override the AgentOS API base URL. Trailing slashes are stripped automatically. |
LETMC_ENVIRONMENT | No | Inferred | Explicit deployment environment: production, staging, development, or test |
Environment inference
If LETMC_ENVIRONMENT is not set, the service infers the environment in this priority order:
LETMC_ENVIRONMENT— explicit override; takes precedence over everything elseVERCEL_ENV— if running on Vercel:productionmaps toproduction,previewmaps tostagingNODE_ENV—productionmaps toproduction,testmaps totest- Default — falls back to
development
Environment values are case-insensitive.
API Reference
Import from @/lib/letmc/config:
import {
isLetmcConfigured,
getLetmcConfig,
getLetmcConfigSafe,
getLetmcConfigDiagnostics,
resetLetmcConfigCache,
} from "@/lib/letmc/config";
isLetmcConfigured(): boolean
Returns true if LETMC_API_KEY is present and non-empty, and the resolved base URL is a valid http/https URL.
Use this to conditionally render integration UI or guard API calls:
if (!isLetmcConfigured()) {
// Show "integration not available" message or return early
return null;
}
getLetmcConfig(): LetmcConfig
Returns the resolved configuration object. Throws with a descriptive error message if the integration is not configured (missing API key or invalid URL).
try {
const config = getLetmcConfig();
// config.apiBaseUrl — e.g. "https://live-api.letmc.com"
// config.apiKey — API key string
// config.environment — "production" | "staging" | "development" | "test"
// config.isProduction — boolean
} catch (err) {
// Handle misconfiguration
}
LetmcConfig type:
interface LetmcConfig {
apiBaseUrl: string; // Fully qualified base URL, no trailing slash
apiKey: string; // API key for authentication
environment: DeploymentEnvironment; // Resolved environment name
isProduction: boolean; // true when environment === "production"
}
getLetmcConfigSafe(): LetmcConfig | null
Returns the resolved config or null if the integration is not configured. Preferred for code paths that should degrade gracefully without throwing.
const config = getLetmcConfigSafe();
if (!config) {
// Integration not configured — skip API call
return;
}
// Proceed with config
getLetmcConfigDiagnostics()
Returns a diagnostic object suitable for admin and debug pages. The API key is never exposed in full — only the first 4 and last 4 characters are returned as a preview.
const diagnostics = getLetmcConfigDiagnostics();
// {
// configured: boolean,
// environment: DeploymentEnvironment,
// apiBaseUrl: string,
// apiKeyPresent: boolean,
// apiKeyPreview: string | null, // e.g. "abcd...wxyz", or null if key < 8 chars
// error: string | null
// }
resetLetmcConfigCache(): void
Clears the in-memory configuration cache. The next call to getLetmcConfig() or getLetmcConfigSafe() will re-read environment variables and rebuild the config.
Testing use only. Do not call this in production code. The cache exists to avoid repeated environment variable reads per cold-start.
resetLetmcConfigCache();
Caching behaviour
The resolved configuration is cached in memory after the first successful call. This means:
- Environment variables are read once per server cold-start.
- Subsequent calls to
getLetmcConfig()orgetLetmcConfigSafe()return the cached value immediately. - If the initial resolution fails (e.g. missing API key), no value is cached, and each call will attempt resolution again.
Error messages
| Condition | Error text |
|---|---|
LETMC_API_KEY not set or empty | LETMC_API_KEY is not set. The AgentOS integration requires an API key... |
LETMC_API_BASE_URL is not a valid URL | LETMC_API_BASE_URL is not a valid URL: "...". Expected a fully qualified URL like "https://live-api.letmc.com". |
Security
- API keys are never written to logs or included in error messages.
- The diagnostics endpoint exposes only a masked preview (
abcd...wxyz) for keys longer than 8 characters. - URL validation enforces
httporhttpsprotocols only — other schemes (e.g.file://,ftp://) are rejected.