Can't Hide Behind the API: Stealing Black-Box Commercial Embedding Models

Manveer Singh Tamber, Jasper Xian, Jimmy Lin · DOI

Abstract: Proprietary embedding models from industry leaders like OpenAI and Cohere are often monetized behind "black-box" APIs, under the assumption that restricted access protects intellectual property. This paper demonstrates that these models can be effectively "stolen" for less than $300. Using black-box distillation techniques, researchers trained open-source BERT models to mimic API outputs, achieving near-parity retrieval performance on both in-domain and out-of-domain benchmarks. These findings suggest that APIs are insufficient shields for embedding technology and highlight an urgent need for more robust security measures.

1. Introduction

The current AI economy relies heavily on commercial embedding models provided by companies such as OpenAI and Cohere. By restricting access to model weights and training data, these providers treat their underlying technology as trade secrets. However, the security of this "API shield" is questionable. This study explores model stealing in the context of text retrieval, where an attacker queries an API to obtain embeddings and uses them to train a smaller, cheaper "thief" model to replicate the original's capabilities.

Comparison of the target commercial embedding models, including dimensions, cost per million tokens, and baseline MTEB retrieval performance.

2. Methodology: Black-Box Distillation

The researchers employed a straightforward distillation process to replicate the target models:

  • Data Collection: The OpenAI text-embedding-3-large and Cohere embed-english-v3.0 APIs were queried using text from the MSMARCO dataset to create pairs of (text, embedding).
  • Student Initialization: Standard open-source models, specifically BERT-base and BERT-large, served as the "thief" students.
  • Alignment and Loss: To handle dimensionality mismatches (e.g., mapping 768-dimensional BERT to 3072-dimensional OpenAI vectors), a learnable linear layer was added. The models were optimized using Cosine Distance Loss to align the student's vector directions with the teacher's.
  • Multi-Teacher Distillation: The study also explored concatenating embeddings from both OpenAI and Cohere to train a single, more robust student model that learns from the strengths of both providers.

3. Experimental Setup

The models were trained on the MSMARCO v1 passage ranking dataset, comprising approximately 8.8 million passages. Evaluation was conducted across two primary benchmarks:

  • TREC Deep Learning (2019/2020): Used for in-domain performance testing on data similar to the training set.
  • BEIR Benchmark: A collection of 18 diverse retrieval tasks (e.g., medical, finance) used to assess zero-shot generalization to out-of-domain data.

4. Results and Analysis

The distilled "thief" models demonstrated remarkable fidelity to their commercial teachers. On TREC-DL tasks, the stolen models achieved performance nearly identical to the original APIs. Notably, the Cohere thief (71.8 nDCG@10) slightly outperformed the actual Cohere API (71.1) in certain settings.

Detailed performance comparison (nDCG@10 and Recall@100) between commercial APIs and distilled BERT-based "thief" models across the BEIR and TREC-DL benchmarks.

Key insights from the results include:

  • The "Backbone" Vulnerability: Stealing from Cohere was significantly easier than from OpenAI. Researchers suspect this is due to a shared architectural "DNA" (BERT-based) between the victim and the thief.
  • Dimensionality Bottlenecks: High-dimensional knowledge (3072-d) can be distilled into much smaller bottlenecks (768-d) with almost no loss in retrieval effectiveness.
  • Efficiency and Cost: The total cost for the most expensive replication was roughly $274 ($156 for API tokens and ~$118 for GPU rental). Furthermore, even with just 100k samples (costing ~$20), the thief models achieved respectable performance.

5. Conclusion and Security Implications

The low barrier to entry for model stealing poses a significant risk to the competitive advantage of commercial AI providers. Current defenses like watermarking appear insufficient. The authors recommend that providers move away from predictable, standard backbones and adopt customized architectures to increase the difficulty of model replication. Both OpenAI and Cohere were notified of these findings prior to publication to encourage the development of better API security in the embedding space.

Summary updated

BibTeX
@inproceedings{tamber2025can,
  author = {Manveer Singh Tamber and Jasper Xian and Jimmy Lin},
  title = {{Can't Hide Behind the API: Stealing Black-Box Commercial Embedding Models}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  doi = {10.18653/v1/2025.findings-naacl.104},
}
Figure