{"id":27874,"library":"infisical-python","title":"Infisical Python SDK","description":"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.","status":"active","version":"2.3.6","language":"python","source_language":"en","source_url":"https://github.com/infisical/sdk","tags":["infisical","secrets","configuration","sdk","secrets-management"],"install":[{"cmd":"pip install infisical-python","lang":"bash","label":"PyPI"}],"dependencies":[],"imports":[{"note":"Breaking import change in v2; the legacy SDK used 'infisical-python' but v2 uses 'infisical'.","wrong":"from infisical_python import InfisicalClient; from infisical.client import InfisicalClient","symbol":"InfisicalClient","correct":"from infisical import InfisicalClient"},{"note":"In v2, secrets are accessed via the client instance, not module-level functions.","wrong":"from infisical import get_secret; infisical.get_secret()","symbol":"get_secret","correct":"client.get_secret('SECRET_NAME')"},{"note":"Method renamed in v2; v0 used get_all_secrets().","wrong":"client.get_all_secrets()","symbol":"list_secrets","correct":"secrets = client.list_secrets()"}],"quickstart":{"code":"from infisical import InfisicalClient\n\nclient = InfisicalClient(token='your_service_token')\n\n# Fetch a single secret\nsecret = client.get_secret('MY_API_KEY', environment='dev', project_id='your_project_id')\nprint(f\"Secret: {secret.get('secret_value')}\")\n\n# List all secrets in environment\nall_secrets = client.list_secrets(environment='dev', project_id='your_project_id')\nfor s in all_secrets:\n    print(s['secret_key'], s['secret_value'])","lang":"python","description":"Initialize client with a service token, then fetch or list secrets."},"warnings":[{"fix":"Migrate to the new v2 API. See migration guide at https://infisical.com/docs/sdks/python/migration.","message":"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.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Create separate client instances for sync and async usage, or use the appropriate method variants (e.g., run until complete in async context).","message":"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.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Uninstall the old package: pip uninstall infisical-python && pip install infisical-python>=2.0.0","message":"Legacy v0.x SDK (pip package 'infisical-python' v0) is deprecated and no longer maintained. Do not install v0.x.","severity":"deprecated","affected_versions":"0.x"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Ensure you have v2.x installed: pip install 'infisical-python>=2.0.0' and import from 'infisical' (not 'infisical-python').","cause":"Installed old package or wrong import path.","error":"ModuleNotFoundError: No module named 'infisical'"},{"fix":"Upgrade to the latest version: pip install --upgrade infisical-python. In v2, use get_secret() on the client.","cause":"Using v1.x (legacy) or a very early v2 build where method names were different.","error":"AttributeError: 'InfisicalClient' object has no attribute 'get_secret'"},{"fix":"Generate a new service token from the Infisical dashboard. Ensure the token is passed as a string without extra whitespace.","cause":"The service token provided is invalid or expired, or the token format is incorrect.","error":"infisical.exceptions.InfisicalError: Invalid token"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}