The google-agentic-commerce/ap2 repository provides resources and code samples for the Agent Payments Protocol (AP2), an initiative aimed at creating a secure and interoperable framework for AI-driven payments. AP2 is designed to facilitate seamless payment interactions between autonomous agents, such as shopping assistants, and payment servers, supporting a future where AI can handle complex commerce tasks safely and efficiently.
The repository is structured to help developers understand, experiment with, and implement AP2 in their own projects. It includes a comprehensive documentation section (docs/) that covers the protocol specification, payment flows, frequently asked questions, and MkDocs sources for generating user-friendly documentation. This ensures that users can grasp the protocol's architecture, security considerations, and interoperability goals.
The code/ directory is the core of the repository, containing the AP2 SDK, reference implementations, and a demo web client. The SDK is primarily written in Python, located at code/sdk/python/ap2/, and provides Pydantic models, canonical JSON schemas, and generated code to define the protocol’s core objects. The SDK is intended to simplify integration of AP2 into agent applications, and a PyPI package is planned for future release, though developers can currently install it directly from the repository.
Reference samples and scenarios are available in code/samples/, with implementations in Python, Go, and Android. These samples demonstrate key AP2 components and payment flows, such as human-present card payments and agent-driven shopping experiences. Each scenario includes a README.md with detailed instructions and a run.sh script to streamline setup and execution. The samples are curated to showcase interoperability across different platforms and programming languages, highlighting AP2’s flexibility.
A demo web client built with Vite and React is provided in code/web-client/, allowing users to interact with agent-driven payment flows in a browser environment. This client serves as a practical example of how AP2 can be integrated into modern web applications.
The repository supports authentication via Google API Key or Vertex AI, catering to both development and production environments. Instructions are provided for setting up credentials using environment variables or .env files, and for authenticating with Google Cloud services via the gcloud CLI or service accounts. This ensures secure access to AI models and payment services during development and deployment.
AP2 samples leverage the Agent Development Kit (ADK) and Gemini 3.1 Flash Lite Preview, but the protocol itself is tool-agnostic, allowing developers to use their preferred frameworks and languages. The repository emphasizes flexibility and encourages experimentation with different agent architectures.
Overall, google-agentic-commerce/ap2 is a comprehensive resource for developers interested in building secure, interoperable, and AI-driven payment solutions. It provides clear documentation, robust SDKs, practical samples, and a demo client, all aimed at accelerating the adoption of agent-based commerce and payments. The project is open-source under the Apache 2.0 license, inviting contributions and collaboration from the broader developer community.