Skip to main content

Create an agent

import swarmnode

swarmnode.api_key = "YOUR_API_KEY"

swarmnode.Agent.create(
name="My Agent",
script="def main(request):\n return 'Hello, world!'",
requirements="requests==2.31.0\npandas==2.1.4",
env_vars="FOO=bar\nBAZ=qux",
python_version="3.11",
)

Returns a Agent object.

requirements and env_vars may include the \n character because they are multiline strings.