Infisical Python SDK

raw JSON →
2.3.6 verified Sat May 09 auth: no python

Official Python SDK for Infisical, a secrets management platform. Version 2.x is a complete rewrite (new SDK) that is not backwards-compatible with the 0.x legacy SDK. Provides programmatic access to secrets, service tokens, and machine identity authentication.

pip install infisical-python
error ModuleNotFoundError: No module named 'infisical'
cause Installed old package or wrong import path.
fix
Ensure you have v2.x installed: pip install 'infisical-python>=2.0.0' and import from 'infisical' (not 'infisical-python').
error AttributeError: 'InfisicalClient' object has no attribute 'get_secret'
cause Using v1.x (legacy) or a very early v2 build where method names were different.
fix
Upgrade to the latest version: pip install --upgrade infisical-python. In v2, use get_secret() on the client.
error infisical.exceptions.InfisicalError: Invalid token
cause The service token provided is invalid or expired, or the token format is incorrect.
fix
Generate a new service token from the Infisical dashboard. Ensure the token is passed as a string without extra whitespace.
breaking Version 2.x is a complete rewrite with a new API design. Code written for the legacy 0.x SDK is incompatible and must be rewritten.
fix Migrate to the new v2 API. See migration guide at https://infisical.com/docs/sdks/python/migration.
gotcha The client initializes synchronously but also offers an async interface. Mixing sync and async methods on the same client instance can lead to hangs or errors.
fix Create separate client instances for sync and async usage, or use the appropriate method variants (e.g., run until complete in async context).
deprecated Legacy v0.x SDK (pip package 'infisical-python' v0) is deprecated and no longer maintained. Do not install v0.x.
fix Uninstall the old package: pip uninstall infisical-python && pip install infisical-python>=2.0.0

Initialize client with a service token, then fetch or list secrets.

from infisical import InfisicalClient

client = InfisicalClient(token='your_service_token')

# Fetch a single secret
secret = client.get_secret('MY_API_KEY', environment='dev', project_id='your_project_id')
print(f"Secret: {secret.get('secret_value')}")

# List all secrets in environment
all_secrets = client.list_secrets(environment='dev', project_id='your_project_id')
for s in all_secrets:
    print(s['secret_key'], s['secret_value'])