Introduction
In this tutorial, you'll learn how to get started with Google's Antigravity 2.0 platform, a new agent-first development environment that allows you to create, manage, and execute AI agents using a command-line interface (CLI) and SDK. This platform is designed to make AI-assisted development more accessible and efficient for developers. By the end of this tutorial, you'll have installed the Antigravity CLI, created your first AI agent, and executed it locally using the Antigravity SDK.
Prerequisites
Before starting this tutorial, you'll need the following:
- A computer running Windows, macOS, or Linux
- Python 3.8 or higher installed on your system
- Basic understanding of command-line tools
- Access to a Google Cloud account with appropriate permissions
Step-by-Step Instructions
1. Install the Antigravity CLI
The first step is to install the Antigravity CLI tool, which will allow you to manage your agents from the command line. Open your terminal or command prompt and run the following command:
pip install antigravity-cli
Why: The CLI is the primary interface for managing your agents. It provides commands for creating, starting, stopping, and monitoring agents without needing a graphical user interface.
2. Set Up Your Google Cloud Credentials
Antigravity 2.0 integrates with Google's AI services, so you'll need to authenticate with your Google Cloud account. Run the following command to initialize the authentication:
gcloud auth login
Why: This step ensures that Antigravity can access Google's AI services, including the Gemini API, which powers the managed agents in Antigravity 2.0.
3. Initialize a New Antigravity Project
Now that your environment is set up, create a new Antigravity project. Navigate to the directory where you want to store your project and run:
antigravity init my-agent-project
Why: This command creates a new project directory with the necessary configuration files and structure for managing your agents in Antigravity.
4. Create Your First AI Agent
Next, you'll create a simple AI agent using the Antigravity SDK. In your project directory, create a new Python file called my_agent.py and add the following code:
from antigravity_sdk import Agent, Task
# Define a simple task for the agent
def simple_task():
return "Hello from Antigravity 2.0!"
# Create an agent
agent = Agent(name="MyFirstAgent")
# Add the task to the agent
agent.add_task(Task(name="greeting", func=simple_task))
# Run the agent
if __name__ == "__main__":
agent.run()
Why: This code defines a basic AI agent that performs a simple task. The Agent class is part of the Antigravity SDK and allows you to define and run tasks in a structured way.
5. Run Your Agent Using the CLI
With your agent defined, you can now run it using the CLI. From your project directory, execute:
antigravity run my_agent.py
Why: The CLI command allows you to execute your agent script directly, ensuring that it runs within the Antigravity environment with all necessary configurations and dependencies.
6. Monitor Your Agent's Execution
While your agent is running, you can monitor its progress using the CLI. Run the following command to list all running agents:
antigravity list
Why: This command helps you keep track of your agents and their current status, which is especially useful when managing multiple agents in a development environment.
7. Explore the Managed Agents Feature
Antigravity 2.0 includes a managed agents feature that allows you to run agents in the cloud using Google's Gemini API. To enable this feature, you can configure your agent to use managed execution by modifying your my_agent.py file:
from antigravity_sdk import Agent, Task
# Define a simple task for the agent
def simple_task():
return "Hello from Antigravity 2.0 (Managed)!"
# Create an agent with managed execution enabled
agent = Agent(name="MyManagedAgent", managed=True)
# Add the task to the agent
agent.add_task(Task(name="greeting", func=simple_task))
# Run the agent
if __name__ == "__main__":
agent.run()
Why: Setting managed=True tells Antigravity to execute your agent using Google's managed infrastructure, which provides scalability and enterprise-grade support.
Summary
In this tutorial, you've learned how to install and use Google's Antigravity 2.0 platform. You've set up the CLI, created your first AI agent using the SDK, and executed it locally. You've also explored how to enable managed execution for your agents using Google's Gemini API. This foundational knowledge will help you build more complex AI agents and workflows in the future.
As you continue to explore Antigravity 2.0, consider experimenting with more complex tasks, integrating with external APIs, and leveraging the enterprise features for production use cases.



