Environment Variables in OpenAPITools
OpenAPITools allows you to set environment variables that will be available to the tools when they execute. This is useful for providing sensitive configuration data to tools without hardcoding values in the tool scripts.
Setting Environment Variables
Set Multiple Variables at Once
adapter.setEnvironmentVariables({
"API_KEY": "your-secret-key",
"GITHUB_SECRET": "https://api.example.com",
});
The setEnvironmentVariables
method accepts an object where:
- Keys are the environment variable names
- Values are the corresponding string values
Add a Single Environment Variable
adapter.addEnvironmentVariable("DATABASE_URL", "postgres://user:password@localhost:5432/mydb");
The addEnvironmentVariable
method allows you to add a single environment variable by specifying:
name
: The name of the environment variablevalue
: The string value for the variable
Things to note
- Security: Use environment variables for sensitive information like API keys and credentials
- Configuration: Set environment variables for any configurable aspects of your tools
// Example: Setting up secure API access
const adapter = new AnthropicAdapter("your_api_key");
// Add credentials for tools to use
adapter.setEnvironmentVariables({
"OPENWEATHER_API_KEY": "your-weather-api-key",
"GOOGLE_MAPS_API_KEY": "your-maps-api-key",
"DATABASE_CONNECTION": "connection-string",
});
// Create a tool handler with these environment variables available
const toolHandler = await adapter.createAnthropicToolHandler(["weather", "maps", "database"]);
Last updated on