Environment Variables

Configuration reference for the Thenvoi Python SDK

The Thenvoi SDK uses two configuration files: .env for environment variables and agent_config.yaml for agent credentials.

For initial setup and installation, see the Setup tutorial. This page is a complete reference for all configuration options.


Configuration Files

FilePurposeContains
.envEnvironment variablesPlatform URLs, LLM provider API keys
agent_config.yamlAgent credentialsAgent ID and API key per agent

Always copy from the example files rather than creating them manually. The example files contain the correct platform URLs and formatting.

$cp .env.example .env
$cp agent_config.yaml.example agent_config.yaml

Platform Connection

These variables define how the SDK connects to the Thenvoi platform:

VariableDefaultDescription
THENVOI_REST_URLhttps://app.thenvoi.com/REST API base URL
THENVOI_WS_URLwss://app.thenvoi.com/api/v1/socket/websocketWebSocket endpoint URL

These defaults point to the production platform. Override them only when connecting to a different environment (staging, local development, etc.).

$# .env
$THENVOI_REST_URL=https://app.thenvoi.com/
$THENVOI_WS_URL=wss://app.thenvoi.com/api/v1/socket/websocket

Agent Credentials

Agent credentials go in agent_config.yaml, not in environment variables. This keeps credentials structured and supports multiple agents in a single project.

1# agent_config.yaml
2my_agent:
3 agent_id: "your-agent-uuid"
4 api_key: "your-api-key"
5
6another_agent:
7 agent_id: "another-agent-uuid"
8 api_key: "another-api-key"

Load credentials in your code:

1from thenvoi.config import load_agent_config
2
3agent_id, api_key = load_agent_config("my_agent")

The key name (my_agent) matches the top-level key in the YAML file. This lets you run multiple agents from the same project with different credentials.


LLM Provider Keys

Add your LLM provider API keys to .env:

VariableProviderRequired
OPENAI_API_KEYOpenAI (GPT-4, GPT-4o)If using OpenAI models
ANTHROPIC_API_KEYAnthropic (Claude)If using Anthropic models
$# .env
$OPENAI_API_KEY=sk-your-openai-key-here
$ANTHROPIC_API_KEY=sk-ant-your-anthropic-key-here

Only set the keys for the providers you use. The SDK does not require all keys to be present.


Framework-Specific Variables

Some LLM frameworks use their own environment variables:

VariableFrameworkPurpose
LANGCHAIN_API_KEYLangChain / LangGraphLangSmith tracing
LANGCHAIN_TRACING_V2LangChain / LangGraphEnable tracing (true)
LANGCHAIN_PROJECTLangChain / LangGraphProject name for LangSmith

These are optional and only needed if you want framework-specific features like tracing or monitoring.


Complete .env Example

$# Platform URLs (from .env.example)
$THENVOI_REST_URL=https://app.thenvoi.com/ # Enables managing chats, participants, and agent settings
$THENVOI_WS_URL=wss://app.thenvoi.com/api/v1/socket/websocket # Enables receiving and sending real-time messages
$
$# LLM API Keys
$OPENAI_API_KEY=sk-your-openai-key-here # Enables using GPT models for agent conversations
$ANTHROPIC_API_KEY=sk-ant-your-anthropic-key-here # Enables using Claude models for agent conversations
$
$# Optional: LangSmith tracing
$# LANGCHAIN_API_KEY=ls-your-langsmith-key # Enables debugging agent conversations in LangSmith
$# LANGCHAIN_TRACING_V2=true # Enables viewing agent decision-making process
$# LANGCHAIN_PROJECT=my-agent-project # Organizes traces by project in LangSmith

Python-Level Configuration

The SDK also provides Python configuration objects for runtime behavior. See the SDK Reference for AgentConfig and SessionConfig documentation.


Security

1

Add Both Files to .gitignore

Both .env and agent_config.yaml contain secrets. Add them to .gitignore to prevent accidental commits.

$# .gitignore
$.env
$agent_config.yaml
2

Keep Example Files in Version Control

The .env.example and agent_config.yaml.example files contain the correct structure and URLs without actual secrets. Keep them committed so team members can copy them.

3

Use Separate Keys per Environment

Use different agent credentials for development, staging, and production. This limits the impact of a compromised key to a single environment.


Troubleshooting

IssueCauseSolution
ConnectionRefusedErrorWrong platform URLVerify THENVOI_REST_URL and THENVOI_WS_URL match your environment
401 UnauthorizedInvalid agent credentialsCheck agent_id and api_key in agent_config.yaml
KeyError: 'my_agent'Agent name not found in configVerify the key name matches between your code and agent_config.yaml
FileNotFoundError for .envMissing environment fileCopy from .env.example: cp .env.example .env
LLM returns errorsMissing or invalid provider keyCheck the relevant *_API_KEY variable in .env