A high level scripting API for CX Agent Studio developers.
Project description
CX Agent Studio Scripting API (CXAS SCRAPI)
A powerful Python API, CLI, and set of Agent Skills for CX Agent Studio to automate, evaluate, and scale your agents with ease.
Important Links: Docs, Examples, Agent Skills, Core SDK
CX Agent Studio Scripting API (CXAS SCRAPI) is an open-source Python scripting API, CLI, and set of Agent Skills for CX Agent Studio. It is designed to simplify building, deploying, and orchestrating agent workflows, from simple tasks to complex systems. It integrates seamlessly with Agentic IDEs like Gemini CLI, Claude Code, and Antigravity, exposing advanced tooling for deep evaluations, real-time latency metrics, offline linting, and conversation history.
Built With
- Python 3.11+
Authentication
Authentication can vary depending on how and where you are interacting with SCRAPI.
Google Colab
If you're using CXAS SCRAPI with a Google Colab notebook, you can add the following to the top of your notebook for easy authentication:
project_id = '<YOUR_GCP_PROJECT_ID>'
# this will launch an interactive prompt that allows you to auth with GCP in a browser
!gcloud auth application-default login --no-launch-browser
# this will set your active project to the `project_id` above
!gcloud auth application-default set-quota-project $project_id
After running the above, Colab will pick up your credentials from the environment and pass them to CXAS SCRAPI directly. No need to use Service Account keys! You can then use CXAS SCRAPI simply like this:
from cxas_scrapi import Apps
project_id = '<YOUR_GCP_PROJECT_ID>'
location = 'us'
app_client = Apps(project_id=project_id, location=location) # <-- Creds will be automatically picked up from the environment
apps_map = app_client.get_apps_map()
Cloud Functions / Cloud Run
If you're using CXAS SCRAPI with Cloud Functions or Cloud Run, CXAS SCRAPI can pick up on the default environment creds used by these services without any additional configuration!
- Add
cxas-scrapito yourrequirements.txtfile - Ensure the Cloud Function / Cloud Run service account has the appropriate Custom Agent / Conversational Agents IAM Role
Once you are setup with the above, your function code can be used easily like this:
from cxas_scrapi import Agents
app_name = '<YOUR_APP_NAME>'
a = Agents(project_id='<YOUR_GCP_PROJECT_ID>', location='global')
agents_map = a.get_agents_map(app_name)
Local Python Environment
Similar to Cloud Functions / Cloud Run, CXAS SCRAPI can pick up on your local authentication creds if you are using the gcloud CLI.
- Install gcloud CLI.
- Run
gcloud init. - Run
gcloud auth login - Run
gcloud auth application-default login - Run
gcloud auth listto ensure your principal account is active.
This will authenticate your principal GCP account with the gcloud CLI, and SCRAPI can pick up the creds from here.
Exceptions and Misc.
If you prefer to explicitly assign Service Account credentials programmatically instead of relying on the environmental application-default, you can pass the path to your JSON key using creds_path.
from cxas_scrapi import Tools
creds_path = '<PATH_TO_YOUR_SERVICE_ACCOUNT_JSON_FILE>'
t = Tools(project_id='<YOUR_GCP_PROJECT_ID>', location='global', creds_path=creds_path)
tools_map = t.get_tools_map('<YOUR_APP_NAME>')
Getting Started
Environment Setup
Set up Google Cloud Platform credentials and install dependencies.
gcloud auth login
gcloud auth application-default login
gcloud config set project <project name>
python3 -m venv venv
source ./venv/bin/activate
pip install -r requirements.txt
Usage
To run a simple bit of code you can do the following:
- Import a Class from
cxas_scrapi - Define your GCP Project and Location
from cxas_scrapi import Apps
# Instantiate your class object and pass in your credentials
app_client = Apps(project_id='<YOUR_GCP_PROJECT_ID>', location='global')
# Retrieve all Apps existing in your project
apps = app_client.list_apps()
for app in apps:
print(app.display_name, app.name)
Library Composition
Here is a brief overview of the CXAS SCRAPI library's structure and the motivation behind that structure.
Core
The src/cxas_scrapi/core directory contains the high level building blocks of CXAS SCRAPI, mapped to core resource types in the CXAS environment (Apps, Agents, Tools, Guardrails, Deployments, Sessions, etc.)
Utils
The src/cxas_scrapi/utils directory contains helper functions and background logic for pagination, response flattening, proto conversions, and external integrations like Google Sheets.
Evals
The src/cxas_scrapi/evals directory provides tools for executing and analyzing agent performance evaluations, including Golden tests and simulation runs, and extracting metrics like latency.
CLI
The src/cxas_scrapi/cli directory implements the command line interface for SCRAPI, offering tools like cxas lint to automate development and validation workflows.
Migration
The src/cxas_scrapi/migration directory contains tools to facilitate transitioning legacy Dialogflow CX agents to CXAS, including agent generation from flows and artifact building.
Documentation
The full documentation site is built with MkDocs Material. To run it locally:
# Install docs dependencies (inside your virtualenv)
pip install -r requirements-docs.txt
# Install the package so API reference pages can render
pip install -e .
# Start the local dev server
mkdocs serve
Open http://127.0.0.1:8000 in your browser. Changes to files in docs/ will reload automatically.
To build the static site without serving:
mkdocs build # output goes to site/
mkdocs build --strict # also fails on warnings (used in CI)
Contributing
We welcome any contributions or feature requests you would like to submit!
- Fork the Project
- Create your Feature Branch (git checkout -b feature/AmazingFeature)
- Commit your Changes (git commit -m 'Add some AmazingFeature')
- Push to the Branch (git push origin feature/AmazingFeature)
- Open a Pull Request
License
Distributed under the Apache 2.0 License. See LICENSE for more information.
Contact
Patrick Marlow - pmarlow@google.com - @kmaphoenix
Project Link: https://github.com/GoogleCloudPlatform/cxas-scrapi
Acknowledgements
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cxas_scrapi-1.0.0.tar.gz.
File metadata
- Download URL: cxas_scrapi-1.0.0.tar.gz
- Upload date:
- Size: 382.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b6c58bfc6ea9d94ef536f9142c9dc2805fa1ffe386b4dcf49058d375d312323
|
|
| MD5 |
2a357746db4a2bc59280b1dade38e6d1
|
|
| BLAKE2b-256 |
474cef7337df326a36c4229071ef36a8d83e360fd65e54a75f74c59fb715ffd7
|
Provenance
The following attestation bundles were made for cxas_scrapi-1.0.0.tar.gz:
Publisher:
release-please.yml on GoogleCloudPlatform/cxas-scrapi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cxas_scrapi-1.0.0.tar.gz -
Subject digest:
3b6c58bfc6ea9d94ef536f9142c9dc2805fa1ffe386b4dcf49058d375d312323 - Sigstore transparency entry: 1356200013
- Sigstore integration time:
-
Permalink:
GoogleCloudPlatform/cxas-scrapi@41d0890eb8d8684a22eafa651461850a8532616a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/GoogleCloudPlatform
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@41d0890eb8d8684a22eafa651461850a8532616a -
Trigger Event:
push
-
Statement type:
File details
Details for the file cxas_scrapi-1.0.0-py3-none-any.whl.
File metadata
- Download URL: cxas_scrapi-1.0.0-py3-none-any.whl
- Upload date:
- Size: 493.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d921fb742a406bb445d4908410e71e19850ec191909e1b859ce98b4fadc2c5e
|
|
| MD5 |
3db44efb1113ab81c47490c41afbc87a
|
|
| BLAKE2b-256 |
6422febe943eed291e49be988fad4fc88c398cb639024b9956e9c36d1d8f3b45
|
Provenance
The following attestation bundles were made for cxas_scrapi-1.0.0-py3-none-any.whl:
Publisher:
release-please.yml on GoogleCloudPlatform/cxas-scrapi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cxas_scrapi-1.0.0-py3-none-any.whl -
Subject digest:
6d921fb742a406bb445d4908410e71e19850ec191909e1b859ce98b4fadc2c5e - Sigstore transparency entry: 1356200065
- Sigstore integration time:
-
Permalink:
GoogleCloudPlatform/cxas-scrapi@41d0890eb8d8684a22eafa651461850a8532616a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/GoogleCloudPlatform
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@41d0890eb8d8684a22eafa651461850a8532616a -
Trigger Event:
push
-
Statement type: