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.set_environment_variables({
"API_KEY": "your-secret-key",
"GITHUB_SECRET": "https://api.example.com",
})
The set_environment_variables
method accepts a dictionary where:
- Keys are the environment variable names
- Values are the corresponding string values
Add a Single Environment Variable
adapter.add_environment_variable("DATABASE_URL", "postgres://user:password@localhost:5432/mydb")
The add_environment_variable
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
adapter = AnthropicAdapter(api_key="your_api_key")
# Add credentials for tools to use
adapter.set_environment_variables({
"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
tool_handler = adapter.create_anthropic_tool_handler(["weather", "maps", "database"])
Last updated on