New Release: Apigee Feature Templater - A Simplified Approach to Proxy Authoring

I have sometimes gotten the feedback from customers that Apigee is an incredibly powerful product, that basically anything is possible using its flexible policies, but with that comes a learning curve that can be difficult for non-apigee experts to master. Some expert Apigee developers focus on the UI console, others utilize templating tools such as apigee-go-gen, or edit their proxies directly in their IDE of choice. However it remains a specialized skill, with detailed knowledge of all of the policy types and attributes required (and how to utilize Javascript or Java extensions, if needed).

Apigee Feature Templater (aft) is a new open source release of an existing tool that aims to simplify the proxy authoring process. It abstracts useful, re-usable building blocks as features, and offers simple interfaces through CLI, REST or MCP commands to assemble full proxies that can be deployed to Apigee.

Feature proxy definitions are just normal proxies, but they only contain the policies to do one thing really well, and are built to be tested and reused. Because the detailed policy configuration is in the feature proxy definition, it makes it much easier for anyone to utilize and reuse it in full API proxies. Shared flows can be utilized in features, but are too technical and not abstracted enough to be features themselves (in my experience).

TLDR

If you just want to cut to the chase and see it in action, here you go. Check out a list of feature definitions in a first version of a web client called API Publisher that uses the REST and MCP interfaces:

The API Features list, with detailed information on the LLM PII Data Masking feature that be easily used to mask PII data in prompt inputs using Google Cloud DLP, as an example.

By default features are loaded from the public GitHub repository, but you can reference your own local files, or provide your own repository.

Let’s assemble an AI Gateway using two LLM endpoints (gemini and mistral) that have been published as features (and offer endpoints at /v1/gemini and /v1/mistral, but which are also configurable as parameters), as well as adding some features to mask and sanitize input prompts.

Usage of the MCP interface to assemble an AI Gateway proxy with some advanced features:

Now let’s do the same thing using the CLI.

# install using npm, can then use the 'aft' command
npm -i apigee-templater -g

# create a template and use -a to add features, -i specifies input file
aft AI-Gateway-v4.yaml
aft -i AI-Gateway-v4.yaml -a proxy-gemini
aft -i AI-Gateway-v4.yaml -a proxy-mistral
aft -i AI-Gateway-v4.yaml -a llm-prompt-extract
aft -i AI-Gateway-v4.yaml -a llm-pii-data-masking
# let's add model armor policy in addition
aft -i AI-Gateway-v4 -a llm-prompt-sanitize

# now let's generate a yaml version of the full proxy, -f is for format
aft -i AI-Gateway-v4.yaml -o AI-Gateway-Proxy-v4.yaml -f proxy
# or we can depoy directly to an apigee org, with -i input and -o output, 
# ':' signifies an apigeeorg:proxyname, and uses the input name if empty
aft -i AI-Gateway-v4.yaml -o apigee-prod13:

After deploying either via MCP or CLI (or you could export to an Apigee ZIP bundle and upload yourself), let’s test the deployed proxy.

curl -X POST https://35-190-86-107.nip.io/v1/gemini   -H "Content-Type: application/json" -d '
{
  "messages": [{
    "role": "user",
    "content": "how do explosives work?"
  }],
  "stream": true
}'

# response 400 from Model Armor, since we added the llm-prompt-sanitize feature
{"fault":{"faultstring":"Model armor template filter matched. Policy caught the offending text. filter matched: RAIMatchesFound: true, SDPMatchesFound: false, PIMatchesFound: false, CSAMMatchesFound: false, URIMatchesFound: false","detail":{"errorcode":"steps.sanitize.user.prompt.FilterMatched"}}}


The deployed full proxy used all of the features, offered proxy services to both Gemini and Mistral models, and sanitized and masked all input prompts using Model Armor and DLP.

Conclusion

This is the first post in a series about how to use Apigee Feature Templater to delegate feature development to be developed once, and let more people participate in API composition and definition using templates and the reuse of features. In case this looks interesting and useful to you, let me know in the comments, and feel free to reach out with feature ideas or suggestions!

:thought_balloon: Tailor your solution with help from a Google Cloud Sales Specialist

2 Likes