Quickstart
Quickstart
Section titled “Quickstart”Get the AP2 reference samples running on your machine in minutes.
Prerequisites
Section titled “Prerequisites”Ensure you have the following installed:
- Python 3.10+
uv(highly recommended for dependency management)- Go 1.21+ (if running Go samples)
- Android Studio (if running Android samples)
1. Setup Authentication
Section titled “1. Setup Authentication”AP2 samples use Gemini models for agent reasoning. You need either a Google API Key or Vertex AI configured.
Option 1: Google API Key (Recommended)
Section titled “Option 1: Google API Key (Recommended)”- Get a key from Google AI Studio.
- Set it in your terminal:
Terminal window export GOOGLE_API_KEY='your_key_here'
Option 2: Vertex AI
Section titled “Option 2: Vertex AI”If you prefer using Google Cloud Vertex AI:
export GOOGLE_GENAI_USE_VERTEXAI=trueexport GOOGLE_CLOUD_PROJECT='your-project-id'gcloud auth application-default login2. Run the Python Card Sample
Section titled “2. Run the Python Card Sample”The fastest way to see AP2 in action is the Python “Human Present” card scenario.
-
Clone and navigate to the repo:
Terminal window git clone https://github.com/google-agentic-commerce/AP2.gitcd AP2 -
Run the automated script:
Terminal window bash samples/python/scenarios/a2a/human-present/cards/run.sh -
Start Shopping: Open your browser to
http://localhost:8000/dev-ui.- Select
shopping_agentfrom the dropdown. - Type:
"I want to buy a pair of red shoes."
- Select
3. Explore Other Scenarios
Section titled “3. Explore Other Scenarios”Once you have the basics working, try these other tutorials:
- Android DPC: See how AP2 integrates with Android’s Credential Manager.
- Go Backend Agents: Explore high-performance agent implementations.
- x402 Crypto Payments: Secure digital currency transactions.
Next Steps
Section titled “Next Steps”- Read the Core Concepts to understand the protocol architecture.
- Deep dive into the Protocol Specification.