{"id":5605,"library":"daytona-api-client-async","title":"Daytona API Client (Async)","description":"The `daytona-api-client-async` library provides an asynchronous Python client for interacting with the Daytona platform. Daytona offers a secure and elastic infrastructure for running AI-generated code within isolated development environments called sandboxes. This client enables programmatic management of these sandboxes, including creation, code execution, and lifecycle operations. The library is part of the larger Daytona SDK ecosystem, which receives frequent updates, often multiple times a week.","status":"active","version":"0.164.0","language":"en","source_language":"en","source_url":"https://github.com/daytonaio/daytona","tags":["api-client","async","development-environments","cloud-development","ai-agents","sandboxes","python-sdk"],"install":[{"cmd":"pip install daytona-api-client-async","lang":"bash","label":"Install daytona-api-client-async"}],"dependencies":[],"imports":[{"note":"While the PyPI package is 'daytona-api-client-async', the high-level asynchronous SDK class is imported from the `daytona` namespace.","wrong":"from daytona_api_client_async import AsyncDaytona","symbol":"AsyncDaytona","correct":"from daytona import AsyncDaytona"},{"symbol":"DaytonaConfig","correct":"from daytona import DaytonaConfig"}],"quickstart":{"code":"import asyncio\nimport os\nfrom daytona import AsyncDaytona, DaytonaConfig\n\nasync def main():\n    # API key can also be set via DAYTONA_API_KEY environment variable\n    # For this example, we fetch it from env or use a placeholder if not set.\n    api_key = os.environ.get('DAYTONA_API_KEY', 'YOUR_API_KEY_HERE')\n    if api_key == 'YOUR_API_KEY_HERE':\n        print(\"WARNING: DAYTONA_API_KEY environment variable not set. Using placeholder.\")\n\n    config = DaytonaConfig(api_key=api_key)\n\n    try:\n        async with AsyncDaytona(config) as daytona:\n            # Create a new sandbox\n            print(\"Creating a new Daytona sandbox...\")\n            sandbox = await daytona.create()\n            print(f\"Sandbox '{sandbox.name}' created with ID: {sandbox.id}\")\n\n            # Execute a command in the sandbox\n            command = \"echo 'Hello from Daytona Sandbox!'\"\n            print(f\"Executing command: '{command}'...\")\n            response = await sandbox.process.exec(command)\n            print(\"Command output:\")\n            print(response.result)\n\n            # Clean up: delete the sandbox\n            print(f\"Deleting sandbox '{sandbox.name}'...\")\n            await daytona.delete(sandbox.id)\n            print(f\"Sandbox '{sandbox.name}' deleted.\")\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n","lang":"python","description":"This quickstart demonstrates how to initialize the asynchronous Daytona client, create a sandbox, execute a simple command within it, and then delete the sandbox. It assumes `DAYTONA_API_KEY` is set as an environment variable or passed explicitly."},"warnings":[{"fix":"Refer to the official migration guide for v0.21.0. Update sandbox creation parameters (`CreateSandboxParams` is now split), utilize the new `SnapshotService`, and adjust for flattened Sandbox object properties.","message":"Major breaking changes were introduced in v0.21.0 (released January 15, 2026). This update refactored the architecture around 'snapshots' instead of legacy pre-built images. Key changes include new parameter types for sandbox creation, a new `SnapshotService`, removal of deprecated Sandbox methods, and flattening of Sandbox instance information. Users on `v0.20.2` or earlier must update their integration.","severity":"breaking","affected_versions":"<=0.20.2"},{"fix":"Always use `from daytona import AsyncDaytona, DaytonaConfig` for the high-level SDK. If `pip install daytona-api-client-async` was explicitly chosen, be aware that you might be using a lower-level component than the primary SDK documented on daytona.io/docs. The recommended installation for the full SDK is `pip install daytona`.","message":"The PyPI package `daytona-api-client-async` is a low-level API client. However, the high-level Python SDK, which includes asynchronous capabilities, is typically installed via `pip install daytona` and its main classes (`AsyncDaytona`, `DaytonaConfig`) are imported from the `daytona` namespace. Direct installation of `daytona-api-client-async` may lead to incorrect import attempts like `from daytona_api_client_async import AsyncDaytona`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Set the `DAYTONA_API_KEY` environment variable (e.g., `export DAYTONA_API_KEY=\"your_key_here\"`) or pass it directly to `DaytonaConfig(api_key=\"your_key_here\")` during client initialization.","message":"The client requires an API key for authentication. If `DAYTONA_API_KEY` is not provided either via an environment variable or explicitly through `DaytonaConfig`, the SDK will raise a `DaytonaError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use the `api_url` parameter instead of `server_url` for configuring the Daytona API endpoint. Example: `DaytonaConfig(api_url=\"https://app.daytona.io/api\")`.","message":"The `server_url` parameter within `DaytonaConfig` is deprecated and will be removed in a future version.","severity":"deprecated","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}