If you have not installed Motus yet, see Installation first.
1. Write the agent
Create a file calledmyapp.py in an empty directory:
myapp.py
- The
@tooldecorator turns any Python function into a tool the LLM can call. Type annotations on parameters are required. Motus uses them to generate the JSON schema the model sees, and the docstring becomes the tool description. OpenAIChatClient()with no arguments readsOPENAI_API_KEYfrom your environment. You can also passapi_key="sk-..."explicitly. Motus ships with clients for OpenAI, Anthropic, Gemini, and OpenRouter. See Models for the full list.ReActAgentcombines a model client, a model name, and a list of tools into a reasoning loop. Pass asystem_promptto give it a persona or standing instructions.- The
agentvariable at module level is what Motus will expose when you serve or deploy. The CLI looks it up by themodule:attributesyntax, as you will see in a moment.
Export your provider key before running locally:Cloud deployments use the Motus model proxy, so this is only needed for local runs.
2. Serve it locally
Start the agent as an HTTP API with one command:http://localhost:8000 that manages sessions and routes messages to your agent. The myapp:agent argument tells Motus to import the myapp module and use its agent attribute.
myapp:agent is a Python import path, not a file path. myapp.py needs to be in your current directory (or installed as a package) so Python can import it. Nested paths like mypackage.mymodule:agent also work.If you see ModuleNotFoundError: No module named 'myapp', make sure you are running the command from the directory that contains myapp.py.3. Chat with your local agent
Open a second terminal and run:weather tool with city="Tokyo", and used the result to answer in natural language.
Drop the quoted message to enter interactive mode:
Ctrl+C. Sessions are created automatically and cleaned up on exit. Use --keep to preserve the session and resume it later with --session <id>.
4. Deploy to Motus Cloud
Stop the local server withCtrl+C. Now deploy the exact same code to Motus Cloud.
Log in
~/.motus/credentials.json. If you do not have a Motus account yet, sign up at console.lithosai.cloud first. Verify you are logged in with:Deploy
The first deploy requires
--name (or --project-id). Motus writes the assigned project ID and other metadata to a motus.toml file in your project root. On subsequent deploys, just run motus deploy with no arguments and it picks up the project from motus.toml.The full loop, recap
You just went from an empty directory to a cloud hosted agent:Next steps
Agents
Dig into ReActAgent’s reasoning loop, memory, guardrails, structured output, and usage tracking.
Tools
Write tools with
@tool, wrap class methods with @tools, connect MCP servers, or run untrusted code in Docker sandboxes.Serving
Session management, worker pools, TTL, webhooks, and the full REST API.
Deployment
Secrets, Git based deploys, ignore rules, and the
motus.toml project file.
