This example runs OpenCode, an open source coding agent, inside a Daytona sandbox. You can interact with OpenCode via a web interface to run automations, build apps, and launch web apps or services using Daytona preview links.
- Secure sandbox execution: The agent operates within a controlled environment, along with code or commands run by the agent.
- 75+ LLM providers: OpenCode supports over 75 different LLM providers, giving you flexibility in choosing your AI model.
- Custom Daytona-aware agent: Preconfigured with a system prompt that understands Daytona sandbox paths and preview links.
- Preview deployed apps: Use Daytona preview links to view and interact with your deployed applications.
- Node.js: Version 18 or higher is required
To run this example, you need to set the following environment variable:
DAYTONA_API_KEY: Required for access to Daytona sandboxes. Get it from Daytona Dashboard
Create a .env file in the project directory with this variable.
-
Install dependencies:
npm install
-
Run the example:
npm run start
When this example is run, the agent follows the following workflow:
- A new Daytona sandbox is created.
- OpenCode AI is installed inside the sandbox.
- A custom agent is configured with Daytona-specific instructions.
- The OpenCode web server starts inside the sandbox.
- You can interact with the agent through the web interface.
- When the script is terminated, the sandbox is deleted.
Creating sandbox...
Installing OpenCode...
Starting OpenCode web server...
Press Ctrl+C to stop.
▄
█▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█
█░░█ █░░█ █▀▀▀ █░░█ █░░░ █░░█ █░░█ █▀▀▀
▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀ ▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀
Web interface: https://3000-1e0f775c-c01b-40e7-8c64-062fd3dadd75.proxy.daytona.works/
Open the provided URL in your browser to interact with the OpenCode agent and start building applications within the sandbox.
See the main project LICENSE file for details.