Requirements
The SDK requires Python 3.12 or higher. Ensure you have a compatible Python version installed.
Installation Methods
Using pip
The simplest way to install the SDK:Using uv (Recommended)
For faster dependency resolution and installation:Using Poetry
Add to yourpyproject.toml:
Development Installation
To install from source for development:Verify Installation
Confirm the SDK is installed correctly:Configuration
Environment Variables
The SDK can be configured using environment variables:Available Environment Variables
Available Environment Variables
| Variable | Description | Default |
|---|---|---|
INFRAHUB_ADDRESS | URL of your Infrahub instance | http://localhost:8000 |
INFRAHUB_API_TOKEN | API authentication token | None |
INFRAHUB_TIMEOUT | Request timeout in seconds | 30 |
INFRAHUB_LOG_LEVEL | Logging level (DEBUG, INFO, WARNING, ERROR) | INFO |
Configuration File
Create ainfrahub.toml configuration file:
- Current directory:
./infrahub.toml - User config:
~/.config/infrahub/infrahub.toml - System config:
/etc/infrahub/infrahub.toml
Programmatic Configuration
Configure directly in your code:Dependencies
The SDK automatically installs these core dependencies:- Pydantic (
>=2.12,<2.13): Data validation - httpx: Async HTTP client
- Rich (
>=13,<14): Terminal formatting - PyArrow (
>=14): Data serialization - GraphQL: API integration
Optional Dependencies
Testing Dependencies
For running tests with the SDK:- pytest
- pytest-asyncio
- pytest-httpx
Development Dependencies
For SDK development:- mypy (type checking)
- ruff (linting)
- black (formatting)
Docker Integration
Use the SDK in a Docker container:Testing the Connection
Create a simple test script:test_connection.py
Troubleshooting
ImportError: No module named 'infrahub_sdk'
ImportError: No module named 'infrahub_sdk'
Ensure the SDK is installed in your active Python environment:If not listed, reinstall the package.
Connection refused or timeout errors
Connection refused or timeout errors
Verify your Infrahub instance is running and accessible:Check your
INFRAHUB_ADDRESS environment variable or configuration.Python version incompatibility
Python version incompatibility
The SDK requires Python 3.12+. Check your version:Use a version manager like pyenv to install Python 3.12:
SSL certificate verification errors
SSL certificate verification errors
For development environments with self-signed certificates:
Next Steps
Quickstart
Build your first application with the SDK
Client Setup
Learn about client configuration options