fromdaytona_sdkimportDaytona,DaytonaConfig,CreateSandboxParams# Initialize the Daytona clientdaytona=Daytona(DaytonaConfig(api_key="YOUR_API_KEY"))# Create the Sandbox instancesandbox=daytona.create(CreateSandboxParams(language="python"))# Run code securely inside the Sandboxresponse=sandbox.process.code_run('print("Sum of 3 and 4 is " + str(3 + 4))')ifresponse.exit_code!=0:print(f"Error running code: {response.exit_code}{response.result}")else:print(response.result)# Clean up the Sandboxdaytona.remove(sandbox)
import{Daytona}from'@daytonaio/sdk'asyncfunctionmain(){// Initialize the Daytona client
constdaytona=newDaytona({apiKey:'YOUR_API_KEY',})letsandboxtry{// Create the Sandbox instance
sandbox=awaitdaytona.create({language:'python',})// Run code securely inside the Sandbox
constresponse=awaitsandbox.process.codeRun('print("Sum of 3 and 4 is " + str(3 + 4))')if(response.exitCode!==0){console.error('Error running code:',response.exitCode,response.result)}else{console.log(response.result)}}catch(error){console.error('Sandbox flow error:',error)}finally{if(sandbox)awaitdaytona.remove(sandbox)}}main().catch(console.error)