  Web applications and APIs face constant threats from malicious actors seeking
to exploit vulnerabilities for illicit gains. These threats necessitate robust
anomaly detection systems capable of identifying malicious API traffic
efficiently despite limited and diverse datasets. This paper proposes a novel
few-shot detection approach motivated by Natural Language Processing (NLP) and
advanced Generative Adversarial Network (GAN)-inspired techniques. Leveraging
state-of-the-art Transformer architectures, particularly RoBERTa, our method
enhances the contextual understanding of API requests, leading to improved
anomaly detection compared to traditional methods. We showcase the technique's
versatility by demonstrating its effectiveness with both Out-of-Distribution
(OOD) and Transformer-based binary classification methods on two distinct
datasets: CSIC 2010 and ATRDF 2023. Our evaluations reveal consistently
enhanced or, at worst, equivalent detection rates across various metrics in
most vectors, highlighting the promise of our approach for improving API
security.
