Skip to content
tnsaiDocs
GitHub

Configuration Reference

Use this page when you need the exact environment variable or programmatic entry point for a TnsAI runtime. Values passed to constructors or builders take precedence over environment variables unless a linked API says otherwise.

Minimum working configuration

For a hosted provider, export its required credential before starting the application:

export OPENAI_API_KEY="replace-with-a-secret"

For a self-hosted OpenAI-compatible endpoint, add the matching base URL:

export OPENAI_BASE_URL="http://127.0.0.1:8000/v1"

Then construct the client and agent as shown in the Quickstart. Constructor or builder arguments can replace these environment values when configuration is application-owned.

LLM provider environment variables

API-key clients fail loudly when neither a constructor argument nor the required environment variable is present. Every client derived from AbstractLLMClient also accepts a base-URL override derived from its key name: for example, ANTHROPIC_API_KEY maps to ANTHROPIC_BASE_URL. The table calls out aliases and required companion values that do not follow that rule.

ClientRequired environment variablesOptional environment variables and notes
OpenAIOPENAI_API_KEYOPENAI_BASE_URL, OPENAI_ORG_ID
AnthropicANTHROPIC_API_KEYANTHROPIC_BASE_URL
GeminiGEMINI_API_KEYGEMINI_BASE_URL
MistralMISTRAL_API_KEYMISTRAL_BASE_URL
GroqGROQ_API_KEYGROQ_BASE_URL
CohereCOHERE_API_KEYCOHERE_BASE_URL
Hugging FaceHUGGINGFACE_API_KEYHUGGINGFACE_BASE_URL. HUGGINGFACE_ENDPOINT is an alias for a dedicated endpoint
OpenRouterOPENROUTER_API_KEYOPENROUTER_BASE_URL, OPENROUTER_SITE_URL, OPENROUTER_SITE_NAME
Azure OpenAIAZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_DEPLOYMENT_IDAZURE_OPENAI_API_VERSION (defaults to 2024-08-01-preview)
MiniMaxMINIMAX_API_KEYMINIMAX_BASE_URL, MINIMAX_GROUP_ID
ZhipuAIZHIPUAI_API_KEYZHIPUAI_BASE_URL
CerebrasCEREBRAS_API_KEYCEREBRAS_BASE_URL
NVIDIA NIMNVIDIA_API_KEYNVIDIA_BASE_URL
DeepInfraDEEPINFRA_API_KEYDEEPINFRA_BASE_URL
Fireworks AIFIREWORKS_API_KEYFIREWORKS_BASE_URL
Together AITOGETHER_API_KEYTOGETHER_BASE_URL
xAI GrokXAI_API_KEYXAI_BASE_URL
IBM watsonx.aiWATSONX_API_KEY, WATSONX_PROJECT_IDWATSONX_BASE_URL
Vertex AIVERTEX_AI_API_KEY, VERTEX_AI_PROJECT_IDVERTEX_AI_LOCATION (defaults to us-central1), VERTEX_AI_BASE_URL
ReplicateREPLICATE_API_KEYREPLICATE_BASE_URL. The framework deliberately uses _API_KEY, not Replicate's _API_TOKEN spelling
DeepSeekDEEPSEEK_API_KEYDEEPSEEK_BASE_URL
PerplexityPERPLEXITY_API_KEYPERPLEXITY_BASE_URL
DatabricksDATABRICKS_API_KEY, DATABRICKS_BASE_URLNone
Qwen Cloud / DashScopeDASHSCOPE_API_KEYDASHSCOPE_BASE_URL
Tencent HunyuanHUNYUAN_API_KEYHUNYUAN_BASE_URL
YiYI_API_KEYYI_BASE_URL
LM StudioNoneLMSTUDIO_BASE_URL, LMSTUDIO_API_KEY. Both are optional for a local server
llama.cpp serverNoneLLAMACPP_BASE_URL, LLAMACPP_API_KEY. Both are optional for a local server
vLLMNoneVLLM_BASE_URL, VLLM_API_KEY. The key is needed only when the endpoint requires authentication
OllamaNoneOLLAMA_BASE_URL, OLLAMA_API_KEY. Both are optional for a local server
AWS BedrockStandard AWS SDK credential chainAWS_REGION

The framework module's provider matrix is the source for provider-specific behavior.

For Vertex AI, a non-default VERTEX_AI_LOCATION must be paired with a matching regional VERTEX_AI_BASE_URL, such as https://europe-west4-aiplatform.googleapis.com. The client reads the location after deriving its default host, so setting only the location would send the regional request path to the default us-central1 hostname.

Databricks has no shared workspace endpoint. Always provide DATABRICKS_BASE_URL. The constructor's placeholder URL is not a usable service configuration.

Channel environment variables

Slack, Discord, WhatsApp, and Email configuration records can also be supplied programmatically. Their fromEnvironment() factories return an empty result when a required group is incomplete, so treat every value in the Required column as a unit. Telegram accepts its token through the adapter constructor or TELEGRAM_BOT_TOKEN.

ChannelRequired environment variablesOptional environment variables
TelegramTELEGRAM_BOT_TOKENNone
Slack Socket ModeSLACK_BOT_TOKEN, SLACK_APP_TOKENSLACK_WEB_API_BASE_URL
Discord GatewayDISCORD_BOT_TOKENDISCORD_APPLICATION_ID, DISCORD_REST_BASE_URL, DISCORD_INTENTS
WhatsApp Cloud APIWHATSAPP_ACCESS_TOKEN, WHATSAPP_PHONE_NUMBER_ID, WHATSAPP_VERIFY_TOKEN, WHATSAPP_APP_SECRETWHATSAPP_GRAPH_BASE_URL, WHATSAPP_WEBHOOK_PORT, WHATSAPP_WEBHOOK_PATH, WHATSAPP_WEBHOOK_BIND_ADDRESS
EmailEMAIL_IMAP_HOST, EMAIL_IMAP_USER, EMAIL_IMAP_PASSWORD, EMAIL_SMTP_HOSTEMAIL_IMAP_PORT, EMAIL_IMAP_SSL, EMAIL_IMAP_FOLDER, EMAIL_SMTP_PORT, EMAIL_SMTP_USER, EMAIL_SMTP_PASSWORD, EMAIL_SMTP_STARTTLS, EMAIL_FROM_ADDRESS, EMAIL_SENDER_ALLOWLIST, EMAIL_POLL_INTERVAL_SECONDS

Built-in tool environment variables

Common tool configuration is intentionally separate from provider and channel credentials:

AreaEnvironment variables
SearchBRAVE_API_KEY, TAVILY_API_KEY
Webhook messagingSLACK_WEBHOOK_URL, DISCORD_WEBHOOK_URL
HTTP private-network opt-inTNSAI_HTTP_ALLOW_PRIVATE=1
File guardTNSAI_FILE_SANDBOX_ROOT, TNSAI_FILE_ALLOWED_EXTS, TNSAI_FILE_MAX_READ_BYTES, TNSAI_FILE_MAX_WRITE_BYTES

See the tool catalog for credentials owned by individual integrations.

AgentBuilder options

AgentBuilder is the programmatic entry point for an agent. The current public surface is grouped below, and its Javadoc has parameter and validation details. The Javadoc ships as tnsai-core-<version>-javadoc.jar in the TnsAI Maven repository.

  • Metadata and lifecycle: id, description, version, autoStart, idleTimeoutMs, tenantId, did, groupMembership
  • Model and conversation: llm, communication, promptStrategy, promptStrategies, promptEnhancer, maxContextTokens
  • Identity and accountability: identity, identities, principal, liabilitySink, authorityScope, paymentBroker
  • Roles, plans, and recovery: role, roles, plan, plans, errorRecoveryScenario, errorRecoveryScenarios, plannerHandle, reasoningStrategy
  • Memory and knowledge: memoryStore, memoryConfig, knowledge, actionKnowledge, knowledgeScope, knowledgeUsageListener
  • Skills and tools: skillStore, skillResolver, skillResolverPolicy, maxActiveSkills, actionExecutor, toolPojos, builtInTools, dynamicTool, dynamicTools, toolCallFilter
  • Reliability and validation: idempotencyStore, relaxValidation, withReachabilityChecks, reachabilityCheckTimeout, validateFully
  • Entry and terminal operations: create, build

The builder does not expose per-call temperature, topP, or maxTokens setters. Configure those on the selected LLM client. For knowledge, pass KnowledgeEntry values to knowledge. Each wraps a KnowledgeSourceConfig and, for a SEARCH entry, optional SearchSettings. See RAG.

Server configuration

The standalone server accepts CLI arguments and environment variables. CLI values win where both forms exist.

SettingCLIEnvironmentDefault or requirement
Port--port <number>TNSAI_PORT7777
Bind address--host <address>TNSAI_HOST127.0.0.1
Public bind opt-in--allow-publicTNSAI_ALLOW_PUBLIC (true)Required for non-loopback binds
Idle shutdown--idle-timeout <minutes>TNSAI_IDLE_TIMEOUT30 minutes
Bearer authenticationNoneTNSAI_TOKENMandatory when public binding is enabled, otherwise authentication is disabled when absent
Default modelNoneTNSAI_MODELglm-5:cloud for the Ollama fallback
Provider selectorNoneTNSAI_PROVIDERThe built-in environment fallback recognizes ollama, and cloud providers require an SPI provider on the classpath
Provider keyNoneTNSAI_API_KEYMust be present to activate the environment provider path. The built-in ollama case ignores the value
Browser originsNoneTNSAI_ALLOWED_ORIGINSComma-separated additions to the origin policy
Workspace rootsNoneTNSAI_WORKSPACE_ROOTPlatform path-separator-delimited, defaults to the current directory
Workspace scan limitNoneTNSAI_WORKSPACE_MAX_FILESOverrides the workspace file limit

For an embedded server, configure TnsServer, BindPolicy, AuthConfig, OriginPolicy, and WorkspaceConfig programmatically. There is no server.yml loader. YAML belongs only to the separate declarative lifecycle-hook registry, where applications explicitly parse hook definitions and register them.

Audit and liability recording has no environment variable. AgentFactory wires no LiabilitySink, so a bundled-server deployment records nothing until you configure one. See Audit agent actions.

Per-agent LLM overrides

The variables above configure a provider process-wide. To override a single agent's provider, model or tuning without recompiling, register an LLMConfigurationSource on the SCOP bridge. Its environment() implementation reads:

TNSAI_LLM_<AGENT>_<FIELD>

<AGENT> is the agent name upper-cased with every non-alphanumeric character replaced by _, and <FIELD> is one of PROVIDER, MODEL, TEMPERATURE, MAX_TOKENS, ENDPOINT, API_KEY_ENV. A Researcher agent's model comes from TNSAI_LLM_RESEARCHER_MODEL. Names differing only in punctuation collide after normalisation.

System properties are checked before environment variables and both are read on every call. A .env file is loaded once per JVM, so editing it (including removing an override) needs a restart.

apiKeyEnv can name any variable the process can see, and endpoint decides where that value is sent as a bearer token. Treat a configuration source as trusted infrastructure. See External LLM Configuration.