{"id":2921,"library":"daytona","title":"Daytona API Client","description":"Daytona is an open-source platform that provides secure, isolated 'sandboxes' – composable computers – for running AI-generated code and streamlining development environments for engineering teams. The Python SDK allows programmatic interaction with these sandboxes, offering functionalities like lifecycle management, code execution, file system operations, and Git integration. It aims to simplify environment setup across various infrastructures. The library is actively maintained with frequent releases, often on a near-daily basis.","status":"active","version":"0.164.0","language":"en","source_language":"en","source_url":"https://github.com/daytonaio/daytona","tags":["api-client","development-environment","ai-agents","sandboxes","cloud-development","workspace-management","sdk"],"install":[{"cmd":"pip install daytona","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Requires Python 3.8 or newer, but less than 4.0.","package":"python","optional":false}],"imports":[{"note":"The primary package name and import path changed from `daytona-sdk` to `daytona` in recent versions. Using `daytona_sdk` will result in an `ImportError` or import an outdated version if both are installed.","wrong":"from daytona_sdk import Daytona","symbol":"Daytona","correct":"from daytona import Daytona"},{"symbol":"DaytonaConfig","correct":"from daytona import Daytona, DaytonaConfig"}],"quickstart":{"code":"import os\nfrom daytona import Daytona, DaytonaConfig\n\n# It is highly recommended to set API_KEY as an environment variable (DAYTONA_API_KEY)\napi_key = os.environ.get('DAYTONA_API_KEY', 'YOUR_DAYTONA_API_KEY')\n\nif api_key == 'YOUR_DAYTONA_API_KEY':\n    print(\"Warning: Please set the DAYTONA_API_KEY environment variable or replace 'YOUR_DAYTONA_API_KEY' with your actual key.\")\n    exit()\n\n# Configure Daytona client (using environment variables by default, or explicitly)\nconfig = DaytonaConfig(api_key=api_key)\ndaytona = Daytona(config)\n\ntry:\n    # Create a new sandbox\n    print(\"Creating a Daytona sandbox...\")\n    sandbox = daytona.create()\n    print(f\"Sandbox created with ID: {sandbox.id} and state: {sandbox.state}\")\n\n    # Run a simple Python command in the sandbox\n    print(\"Running 'Hello World!' in the sandbox...\")\n    response = sandbox.process.code_run('print(\"Hello World from Daytona sandbox!\")')\n    print(f\"Sandbox output: {response.result}\")\n    print(f\"Exit code: {response.exit_code}\")\n\n    # Clean up the sandbox\n    print(f\"Deleting sandbox {sandbox.id}...\")\n    daytona.delete(sandbox)\n    print(\"Sandbox deleted successfully.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    # Add more specific error handling as per warnings below\n","lang":"python","description":"This quickstart demonstrates how to initialize the Daytona client, create a sandbox, execute Python code within it, and then clean up the sandbox. Authentication is handled via an API key, ideally from an environment variable."},"warnings":[{"fix":"Update `pip install daytona-sdk` to `pip install daytona` and `from daytona_sdk import Daytona` to `from daytona import Daytona`.","message":"The package name and import path for the Python SDK changed from `daytona-sdk` to `daytona`. Code using `pip install daytona-sdk` or `from daytona_sdk import Daytona` will fail or use an outdated client.","severity":"breaking","affected_versions":"<=0.100.0 (approximate, based on deprecation timeline)"},{"fix":"Update `except DaytonaError as exc: if 'message text' in str(exc):` patterns to catch specific exceptions like `except DaytonaNotFoundError:` or `except DaytonaAuthenticationError:`.","message":"Error handling has been standardized to use specific, semantically meaningful exception subclasses (e.g., `DaytonaNotFoundError`, `DaytonaAuthenticationError`) instead of the generic `DaytonaError`. While `DaytonaError` still acts as a catch-all, relying on string parsing of error messages to differentiate failures is now brittle and may break.","severity":"breaking","affected_versions":"Introduced in v0.163.0 (and discussed earlier), affects versions where specific error types are preferred over string parsing."},{"fix":"Ensure all Daytona-related environment variables in `.env` files are prefixed with `DAYTONA_` (e.g., `API_KEY` should be `DAYTONA_API_KEY`).","message":"The Python SDK's dotenv handling (loading environment variables from `.env` files) has been made more isolated. Only environment variables prefixed with `DAYTONA_` are now loaded, preventing unintended pollution of the global environment.","severity":"gotcha","affected_versions":">=0.157.0"},{"fix":"Regularly review release notes for the `daytona` package. Consider using version pinning in `requirements.txt` (e.g., `daytona~=0.164.0`) to control updates, but be prepared to update frequently to leverage new features and bug fixes.","message":"The Daytona SDK undergoes rapid development with frequent minor version releases (often daily or every few days). While this ensures continuous improvement, users should plan for regular updates and monitor release notes for changes that might affect their applications.","severity":"gotcha","affected_versions":"All recent versions (v0.x.x)"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}