Building a Secure and Interoperable Future for AI-Driven Payments.
3,175
stars
54
commits
Python
primary language
Jun 17, 2026
updated
This repository contains code samples and demos of the Agent Payments Protocol.
These samples use Agent Development Kit (ADK) and Gemini 3.1 Flash Lite Preview.
The Agent Payments Protocol doesn't require the use of either. While these were used in the samples, you're free to use any tools you prefer to build your agents.
The top-level layout is:
docs/ — specification, flows, FAQ, and MkDocs sources.code/ — all source code, organized by artifact:
code/sdk/ — the AP2 SDK (Python lives at
code/sdk/python/ap2/).code/samples/ — reference implementations and
scenarios.code/web-client/ — the demo web client
(Vite + React).The samples directory contains a collection of curated scenarios meant to
demonstrate the key components of the Agent Payments Protocol.
The scenarios can be found in:
code/samples/python/scenarios — Python.code/samples/go/scenarios — Go.code/samples/android/scenarios — Android.Each scenario contains:
README.md file describing the scenario and instructions for running it.run.sh script to simplify the process of running the scenario locally.This demonstration features various agents and servers, with most source code
located in code/samples/python/src.
Scenarios that use an Android app as the shopping assistant have their source
code in code/samples/android; Go roles live in
code/samples/go.
For the SDK API reference see
code/sdk/python/ap2/sdk/README.md.
uv package managerYou can authenticate using either a Google API Key or Vertex AI.
For either method, you can set the required credentials as environment variables in your shell or place them in a .env file at the root of your project.
Obtain a Google API key from Google AI Studio.
Set the GOOGLE_API_KEY environment variable.
As an environment variable:
export GOOGLE_API_KEY='your_key'
In a .env file:
GOOGLE_API_KEY='your_key'
Configure your environment to use Vertex AI.
As environment variables:
export GOOGLE_GENAI_USE_VERTEXAI=true
export GOOGLE_CLOUD_PROJECT='your-project-id'
export GOOGLE_CLOUD_LOCATION='global' # or your preferred region
In a .env file:
GOOGLE_GENAI_USE_VERTEXAI=true
GOOGLE_CLOUD_PROJECT='your-project-id'
GOOGLE_CLOUD_LOCATION='global'
Authenticate your application.
Using the gcloud CLI:
gcloud auth application-default login
Using a Service Account:
export GOOGLE_APPLICATION_CREDENTIALS='/path/to/your/service-account-key.json'
To run a specific scenario, follow the instructions in its README.md. It will
generally follow this pattern:
Navigate to the root of the repository.
cd AP2
Run the run script to install dependencies & start the agents. The exact path depends on the scenario — for example, the human-present card payment flow:
bash code/samples/python/scenarios/a2a/human-present/cards/run.sh
Other scenarios live alongside it under
code/samples/python/scenarios/, code/samples/go/scenarios/, and
code/samples/android/scenarios/ (see each scenario's README.md
for the exact invocation).
Navigate to the Shopping Agent URL and begin engaging.
The protocol's core objects are defined under
code/sdk/python/ap2/ — Pydantic models in
models/ and
sdk/generated/, canonical JSON schemas
in schemas/. A PyPI package will be published
at a later time. Until then, you can install the package directly using this
command:
uv pip install git+https://github.com/google-agentic-commerce/AP2.git@main
Python
62.7%
TypeScript
13.5%
Kotlin
9.6%
Go
7.1%
SCSS
4.1%
Shell
2.6%
Building a Secure and Interoperable Future for AI-Driven Payments.
3,175
stars
54
commits
Python
primary language
Jun 17, 2026
updated
This repository contains code samples and demos of the Agent Payments Protocol.
These samples use Agent Development Kit (ADK) and Gemini 3.1 Flash Lite Preview.
The Agent Payments Protocol doesn't require the use of either. While these were used in the samples, you're free to use any tools you prefer to build your agents.
The top-level layout is:
docs/ — specification, flows, FAQ, and MkDocs sources.code/ — all source code, organized by artifact:
code/sdk/ — the AP2 SDK (Python lives at
code/sdk/python/ap2/).code/samples/ — reference implementations and
scenarios.code/web-client/ — the demo web client
(Vite + React).The samples directory contains a collection of curated scenarios meant to
demonstrate the key components of the Agent Payments Protocol.
The scenarios can be found in:
code/samples/python/scenarios — Python.code/samples/go/scenarios — Go.code/samples/android/scenarios — Android.Each scenario contains:
README.md file describing the scenario and instructions for running it.run.sh script to simplify the process of running the scenario locally.This demonstration features various agents and servers, with most source code
located in code/samples/python/src.
Scenarios that use an Android app as the shopping assistant have their source
code in code/samples/android; Go roles live in
code/samples/go.
For the SDK API reference see
code/sdk/python/ap2/sdk/README.md.
uv package managerYou can authenticate using either a Google API Key or Vertex AI.
For either method, you can set the required credentials as environment variables in your shell or place them in a .env file at the root of your project.
Obtain a Google API key from Google AI Studio.
Set the GOOGLE_API_KEY environment variable.
As an environment variable:
export GOOGLE_API_KEY='your_key'
In a .env file:
GOOGLE_API_KEY='your_key'
Configure your environment to use Vertex AI.
As environment variables:
export GOOGLE_GENAI_USE_VERTEXAI=true
export GOOGLE_CLOUD_PROJECT='your-project-id'
export GOOGLE_CLOUD_LOCATION='global' # or your preferred region
In a .env file:
GOOGLE_GENAI_USE_VERTEXAI=true
GOOGLE_CLOUD_PROJECT='your-project-id'
GOOGLE_CLOUD_LOCATION='global'
Authenticate your application.
Using the gcloud CLI:
gcloud auth application-default login
Using a Service Account:
export GOOGLE_APPLICATION_CREDENTIALS='/path/to/your/service-account-key.json'
To run a specific scenario, follow the instructions in its README.md. It will
generally follow this pattern:
Navigate to the root of the repository.
cd AP2
Run the run script to install dependencies & start the agents. The exact path depends on the scenario — for example, the human-present card payment flow:
bash code/samples/python/scenarios/a2a/human-present/cards/run.sh
Other scenarios live alongside it under
code/samples/python/scenarios/, code/samples/go/scenarios/, and
code/samples/android/scenarios/ (see each scenario's README.md
for the exact invocation).
Navigate to the Shopping Agent URL and begin engaging.
The protocol's core objects are defined under
code/sdk/python/ap2/ — Pydantic models in
models/ and
sdk/generated/, canonical JSON schemas
in schemas/. A PyPI package will be published
at a later time. Until then, you can install the package directly using this
command:
uv pip install git+https://github.com/google-agentic-commerce/AP2.git@main
Python
62.7%
TypeScript
13.5%
Kotlin
9.6%
Go
7.1%
SCSS
4.1%
Shell
2.6%