Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
md 137 lines 3.6 KB
Rendered Raw
1 # Configuration
2
3 This guide explains how to configure the Composio SDK using environment variables and initialization options.
4
5 ## Environment Variables
6
7 The SDK supports several environment variables for configuration:
8
9 ### Core Configuration
10
11 - `COMPOSIO_API_KEY`: Your Composio API key
12
13 - Required for authentication
14 - Can be obtained from [Composio Dashboard](https://app.composio.dev)
15 - Can also be set via SDK initialization or user config file
16
17 - `COMPOSIO_BASE_URL`: Custom API base URL
18 - Optional
19 - Default: `https://backend.composio.dev`
20 - Use this to point the SDK to a different API endpoint
21
22 ### Logging Configuration
23
24 - `COMPOSIO_LOG_LEVEL`: Controls the verbosity of SDK logs
25 - Values: `silent`, `error`, `warn`, `info`, `debug`
26 - Default: `info`
27 - Hierarchy (from highest to lowest priority):
28 - `silent`: No logs
29 - `error`: Only critical errors
30 - `warn`: Warnings and errors
31 - `info`: General information, warnings, and errors
32 - `debug`: Detailed debugging information
33
34 ### Development and Testing
35
36 - `NODE_ENV`: Environment mode
37
38 - Values: `development`, `production`, `test`
39 - Affects:
40 - Telemetry collection (disabled in development/test)
41 - Error handling verbosity
42 - Version check notifications
43
44 - `DEVELOPMENT`: Development mode flag
45
46 - Set to any value to enable development mode
47 - Enables additional debugging features
48 - Shows more verbose logs
49
50 - `CI`: CI environment flag
51 - Set to any value to indicate CI environment
52 - Affects certain behaviors like version checks
53
54 ### Telemetry
55
56 - `COMPOSIO_DISABLE_TELEMETRY`: Disable telemetry collection
57 - Set to `"true"` to disable
58 - Default: `"false"`
59 - Alternative to `allowTracking` initialization option
60
61 ## SDK Initialization Options
62
63 When initializing the SDK, you can provide configuration through the constructor:
64
65 ```typescript
66 const composio = new Composio({
67 apiKey: 'your-api-key', // Override COMPOSIO_API_KEY
68 baseURL: 'custom-url', // Override COMPOSIO_BASE_URL
69 allowTracking: false, // Disable telemetry
70 allowTracing: true, // Enable tracing
71 provider: new CustomProvider(), // Custom provider
72 host: 'mcp', // host where the sdk is being used
73 });
74 ```
75
76 ### Configuration Priority
77
78 When multiple configuration sources are present, the SDK follows this priority order:
79
80 1. Constructor parameters
81 2. Environment variables
82 3. User config file
83 4. Default values
84
85 ## Examples
86
87 ### Development Setup
88
89 ```bash
90 # Development environment with debug logging
91 export NODE_ENV=development
92 export COMPOSIO_LOG_LEVEL=debug
93 export COMPOSIO_API_KEY=your-api-key
94 ```
95
96 ### Production Setup
97
98 ```bash
99 # Production environment with minimal logging
100 export NODE_ENV=production
101 export COMPOSIO_LOG_LEVEL=error
102 export COMPOSIO_API_KEY=your-api-key
103 ```
104
105 ### Testing Setup
106
107 ```bash
108 # Test environment with telemetry disabled
109 export NODE_ENV=test
110 export COMPOSIO_DISABLE_TELEMETRY=true
111 export COMPOSIO_API_KEY=your-test-api-key
112 ```
113
114 ## Best Practices
115
116 1. **Environment-specific Configuration**
117
118 - Use different log levels for different environments
119 - Enable detailed logging in development
120 - Use minimal logging in production
121
122 2. **Security**
123
124 - Never commit API keys to version control
125 - Use environment variables or secure secrets management
126 - Consider using different API keys for different environments
127
128 3. **Telemetry**
129
130 - Enable telemetry in production for better support
131 - Disable telemetry in development and testing
132 - Use custom telemetry transport for specific needs
133
134 4. **Error Handling**
135 - Set appropriate log levels for error tracking
136 - Use debug level during development
137 - Use error or warn level in production