Nothing beyond what the entry states.
@geertjanklaps/cds-toon-ai-protocol-adapter
A protocol adapter that serves CAP data as TOON — Token-Oriented Object Notation — instead of JSON, so a payload bound for a language model costs fewer tokens to send.
The cost nobody budgets for: JSON spends tokens on punctuation and repeated keys, and every one is billed on the way into a model. The adapter converts in both directions at the protocol layer, in a REST variant and an OData one, so the service code and the model stay as they were and only the wire format changes. It counts tokens on both sides and logs the comparison, which is how you find out whether it earned its place.
Facts
Where it sits
Who is behind it
In the atlas: maintains 4, contributes to 11, wrote 4@geert-janklapsmaintainer
Before choosing this
Conditions
LicenceSAP Developer License Agreement 3.2 CAP§ 1, 2, 3A cds-plugin is used with SAP CAP materials, or an artifact is explicitly identified as a CAP plugin or application.
- § 1 License. Productive customer applications are limited to SAP BTP or another SAP-licensed platform, and mass extraction to a non-SAP product is restricted except where solely required for SAP interoperability.
- § 2 Intellectual Property. The agreement retains SAP's rights in the covered materials and limits making APIs, tools or software available to third parties, while preserving ownership of customer applications subject to SAP's underlying rights.
- § 3 Artificial Intelligence Training. The agreement prohibits use of the covered materials and customer applications for training artificial-intelligence models or systems.
Also, from LLM integration§ 3: Calling a model for inference is not automatically AI training. Section 3 matters when the covered material or application participates in training, model development, refinement or the text-and-data-mining uses it names.
What it declares
Every artifact
- Type
- CDS plugin
- Origin
- Independently maintained
- Runtime
- Node.js
As a CDS plugin
- Declared for
- >=9
- Distributed through
- npm
Tasks this contributes to
Cut the tokens a CAP service spends sending its data to a modelThe same rows a CAP service already hands a model are sent in fewer tokens, so the bill and the latency fall without the service code or the model changing.
Connections
Calling a language model with tenant and credential handling solved
Download
Install
npm add @geertjanklaps/cds-toon-ai-protocol-adapterDerived from the package name. No recipe recorded; the README has the configuration.
Learn more
- cds-toon-ai-protocol-adapter: a pragmatic way to cut AI token costs using SAP CAPcds-toon-ai-protocol-adapter: a pragmatic way to cut AI token costs using SAP CAPNames a cost most CAP-plus-LLM writing ignores: every JSON payload streamed to a model is billed by its verbosity, in latency as well as money. The plugin brings TOON — Token-Oriented Object Notation — to a CAP service so the wire format changes without the service code doing so, in a REST variant and an OData one, with token counts reported on both sides.published 2026-01-25Geert-Jan Klaps, SAP Community
README
quoted from geert-janklaps/cds-toon-ai-protocol-adapter under MIT, readTOON AI Protocol Adapter Plugin for SAP CAP
Token-Oriented Object Notation (TOON) protocol adapter for SAP Cloud Application Programming Model (CAP)
Overview
The TOON AI Protocol Adapter Plugin extends SAP Cloud Application Programming Model (CAP) with support for the TOON (Token-Oriented Object Notation) format. This plugin provides automatic conversion between JSON and TOON format, optimizing data exchange for AI applications by typically reducing token counts while maintaining data integrity.
Key Features
- 🚀 Two Protocol Variants: REST-based (
toon) and OData-based (toon-odata) adapters - 🔄 Bidirectional Conversion: Automatic JSON ↔ TOON format conversion
- 📊 Token Count Optimization: Built-in token statistics and smart content-type selection
- 🔧 Configurable Processing: Flexible request/response processing controls
- 📈 Performance Monitoring: Real-time token count comparison and logging
- 🔌 Plugin Architecture: Easy integration with existing CAP applications

Installation
npm install @geertjanklaps/cds-toon-ai-protocol-adapter
Dependencies
- @sap/cds: >=9 (peer dependency)
- @toon-format/toon: ^2.1.0
- tokenx: ^1.3.0
Quick Start
1. Basic Service Configuration
Define a CAP service with TOON protocol support:
// srv/my-service.cds
@protocol: ['toon']
service MyTOONService {
}
2. Alternative: OData + TOON Protocol
For OData compatibility with TOON optimization:
// srv/my-service.cds
@protocol: ['toon-odata']
service MyTOONODataService {
}
Protocol Endpoints
The plugin automatically creates endpoints for your services:
REST Protocol (@protocol: ['toon'])
- Base URL:
http://localhost:4004/toon/ - Service Path:
/toon/{service-name}/{function-or-action} - Example:
GET /toon/my-toon-service/getData
OData Protocol (@protocol: ['toon-odata'])
- Base URL:
http://localhost:4004/toon-odata/ - Service Path:
/toon-odata/{service-name}/{function-or-action} - Example:
GET /toon-odata/my-toon-odata-service/getData
Configuration
Configure the plugin behavior in your package.json:
{
"cds": {
"toonAdapter": {
"requestProcessingEnabled": false,
"responseProcessingEnabled": true,
"logTokenStatistics": true,
"autoDetermineResponseContentType": true
}
}
}
Configuration Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
requestProcessingEnabled | boolean | false | Enable automatic conversion of incoming TOON requests to JSON |
responseProcessingEnabled | boolean | true | Enable automatic conversion of JSON responses to TOON format |
logTokenStatistics | boolean | true | Log token count comparisons between JSON and TOON formats |
autoDetermineResponseContentType | boolean | true | Automatically choose between JSON/TOON based on token efficiency |
Usage Examples
Making Requests
JSON Request (Standard)
GET /toon-odata/catalog/Books?$select=createdAt,createdBy,modifiedAt,modifiedBy,ID,title,author_ID,genre_ID,stock,price,currency_code
Content-Type: application/json
Response Formats
JSON Response (auto-selected when more efficient)
{
"@odata.context": "$metadata#Books",
"value": [
{
"createdAt": "2026-01-25T18:27:05.907Z",
"createdBy": "anonymous",
"modifiedAt": "2026-01-25T18:27:05.907Z",
"modifiedBy": "anonymous",
"ID": 201,
"title": "Wuthering Heights",
"author_ID": 101,
"genre_ID": 11,
"stock": 12,
"price": 11.11,
"currency_code": "GBP"
},
{
"createdAt": "2026-01-25T18:27:05.907Z",
"createdBy": "anonymous",
"modifiedAt": "2026-01-25T18:27:05.907Z",
"modifiedBy": "anonymous",
"ID": 207,
"title": "Jane Eyre",
"author_ID": 107,
"genre_ID": 11,
"stock": 11,
"price": 12.34,
"currency_code": "GBP"
},
{
"createdAt": "2026-01-25T18:27:05.907Z",
"createdBy": "anonymous",
"modifiedAt": "2026-01-25T18:27:05.907Z",
"modifiedBy": "anonymous",
"ID": 251,
"title": "The Raven",
"author_ID": 150,
"genre_ID": 16,
"stock": 333,
"price": 13.13,
"currency_code": "USD"
},
{
"createdAt": "2026-01-25T18:27:05.907Z",
"createdBy": "anonymous",
"modifiedAt": "2026-01-25T18:27:05.907Z",
"modifiedBy": "anonymous",
"ID": 252,
"title": "Eleonora",
"author_ID": 150,
"genre_ID": 16,
"stock": 555,
"price": 14,
"currency_code": "USD"
},
{
"createdAt": "2026-01-25T18:27:05.907Z",
"createdBy": "anonymous",
"modifiedAt": "2026-01-25T18:27:05.907Z",
"modifiedBy": "anonymous",
"ID": 271,
"title": "Catweazle",
"author_ID": 170,
"genre_ID": 13,
"stock": 22,
"price": 150,
"currency_code": "JPY"
}
]
}
TOON Response (default when responseProcessingEnabled: true)
[5]{createdAt,createdBy,modifiedAt,modifiedBy,ID,title,author_ID,genre_ID,stock,price,currency_code}:
"2026-01-25T18:27:05.907Z",anonymous,"2026-01-25T18:27:05.907Z",anonymous,201,Wuthering Heights,101,11,12,11.11,GBP
"2026-01-25T18:27:05.907Z",anonymous,"2026-01-25T18:27:05.907Z",anonymous,207,Jane Eyre,107,11,11,12.34,GBP
"2026-01-25T18:27:05.907Z",anonymous,"2026-01-25T18:27:05.907Z",anonymous,251,The Raven,150,16,333,13.13,USD
"2026-01-25T18:27:05.907Z",anonymous,"2026-01-25T18:27:05.907Z",anonymous,252,Eleonora,150,16,555,14,USD
"2026-01-25T18:27:05.907Z",anonymous,"2026-01-25T18:27:05.907Z",anonymous,271,Catweazle,170,13,22,150,JPY
Token Count Optimization
The plugin provides intelligent token count optimization:
Automatic Content Type Selection
When autoDetermineResponseContentType is enabled:
- JSON: Used when JSON format has fewer tokens
- TOON: Used when TOON format has fewer tokens (typical case)
Token Statistics Logging
When logTokenStatistics is enabled, the plugin logs:
[toon] - Token count - JSON: 150, TOON: 95, Difference: 55 (36.7%)
Advanced Configuration
Custom Protocol Registration
The plugin automatically registers protocols, but you can customize them:
// cds-plugin.js
const cds = require("@sap/cds");
cds.protocol.toon = {
path: "/custom-toon",
impl: "@geertjanklaps/cds-toon-ai-protocol-adapter",
};
Environment-Specific Settings
{
"cds": {
"profiles": {
"production": {
"toonAdapter": {
"logTokenStatistics": false,
"autoDetermineResponseContentType": true
}
},
"development": {
"toonAdapter": {
"logTokenStatistics": true,
"autoDetermineResponseContentType": false
}
}
}
}
}
Testing Your Implementation
Use the provided test files as reference:
### OData GET request
GET http://localhost:4004/odata/v4/catalog/Books?$select=createdAt,createdBy,modifiedAt,modifiedBy,ID,title,author_ID,genre_ID,stock,price,currency_code
Content-Type: application/json; charset=utf-8
Authorization: Basic alice:
### TOON OData GET Request
GET http://localhost:4004/toon-odata/catalog/Books?$select=createdAt,createdBy,modifiedAt,modifiedBy,ID,title,author_ID,genre_ID,stock,price,currency_code
Content-Type: application/json; charset=utf-8
Authorization: Basic alice:
When to Use
Ideal Use Cases
- AI/LLM Integration: Optimize token usage for AI model communication
- Large Data Payloads: Reduce bandwidth and token costs for complex responses
- Real-time Applications: Minimize payload size for faster transmission
- Cost Optimization: Reduce AI API costs through token count reduction
Performance Benefits
- Token Reduction: Typically 20-50% fewer tokens compared to JSON
- Bandwidth Optimization: Smaller payload sizes
- AI Cost Reduction: Lower token consumption in AI model interactions
API Reference
Adapters
TOONAdapter
Extends SAP CAP's REST adapter with TOON protocol support.
TOONODataAdapter
Extends SAP CAP's OData adapter with TOON protocol support.
Troubleshooting
Common Issues
-
Plugin Not Loading
- Ensure plugin is in dependencies, not devDependencies
- Check CDS version compatibility (>=9 required)
-
TOON Endpoints Not Available
- Verify service has
@protocolannotation - Check service registration in CDS
- Verify service has
-
Token Statistics Not Showing
- Enable
logTokenStatistics: truein configuration - Check log level configuration
- Enable
Debug Logging
Enable debug logging:
DEBUG=toon cds watch
Contributing
Contributions are welcome! Please submit pull requests to the GitHub repository.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- GitHub Issues: Report bugs or request features
- Documentation: Check the inline code documentation for detailed API information
Related Projects
- @toon-format/toon: Core TOON format implementation
- @sap/cds: SAP Cloud Application Programming Model
- tokenx: Token counting utilities
History
Others providing
Compare all 15 on the LLM integration page →- SAP AI CoreSAP AI CoreSAP's AI service on BTP: the runtime for AI assets, and through the Generative AI Hub inside it the access to foundation models, the orchestration service with its templating, masking, filtering and grounding modules, the Prompt Registry and Document Grounding.sap official, btpAI runtime on BTP with the Generative AI Hub
- cap-java/cds-aicap-java/cds-aiBridges CAP Java to SAP AI Core and adds AI-powered field recommendations to Fiori draft UIs, as two alpha Maven modules with mock fallbacks for local development.sap official, capBridge from CAP Java to SAP AI Core, with Fiori field recommendations
- @cap-js/ai@cap-js/aiOut-of-the-box value-help recommendations powered by SAP RPT-1, SAP AI Core as a standard CAP service, and an experimental local embedding model behind SQLite's vector functions.sap official, capValue-help recommendations and SAP AI Core as a CAP service
- cap-llm-plugincap-llm-pluginGenerative AI in a CAP application with the sensitive fields anonymised through SAP HANA before the prompt leaves, so the model never sees the confidential half.independent, capGenerative AI in CAP with fields anonymised through SAP HANA
- cap-decisionscap-decisionsAdds a decisions service to a CAP Node.js application that answers typed questions about one text or JSON state through an HTTP decision endpoint.independent, capCAP service for typed decisions about one text or JSON state
- @jerome-benoit/sap-ai-provider@jerome-benoit/sap-ai-providerA provider for the Vercel AI SDK that speaks to SAP AI Core through its orchestration or foundation models API, so an application written against that SDK runs on SAP's models without being rewritten.independent, capVercel AI SDK provider for SAP AI Core
- ui5-cap-ai-featuresui5-cap-ai-featuresBoth halves of an AI text feature in one package: a CDS plugin serving an AIService over SAP AI Core's Orchestration Service, and the be.wl.ai UI5 control library that calls exactly that service.independent, capCDS plugin and UI5 controls for AI text features via SAP AI Core
- @sap-ai-sdk/ai-api@sap-ai-sdk/ai-apiThe AI Core API surface of SAP's AI SDK, covering deployments, configurations and the rest of the control plane, as opposed to calling a model.sap official, capAI Core control plane API surface of SAP's AI SDK
- @sap-ai-sdk/core@sap-ai-sdk/coreThe shared internals that the packages of SAP's AI SDK build on, which its own readme says are not meant to be depended on directly.sap official, capShared internals of SAP's AI SDK
- @sap-ai-sdk/foundation-models@sap-ai-sdk/foundation-modelsThe package of SAP's AI SDK that calls foundation models through SAP AI Core and the Generative AI Hub, and the one an application actually reaches for.sap official, capClient for foundation models via SAP AI Core and Generative AI Hub
- @sap-ai-sdk/orchestration@sap-ai-sdk/orchestrationThe Orchestration Service client of SAP's AI SDK, which applies templating, grounding, filtering and masking around a model call rather than in the application.sap official, capOrchestration Service client for templating, grounding and masking
- @sap-ai-sdk/prompt-registry@sap-ai-sdk/prompt-registryA package for keeping prompts in SAP's prompt registry rather than in the codebase, so changing a prompt is not a deployment.sap official, capClient for prompts kept in SAP's prompt registry
- @saptarishi/cds-plugin-llm@saptarishi/cds-plugin-llmA CAP service kind that puts eleven model providers behind one chat, stream, embed and batch interface, so which backend a service calls is a profile in package.json rather than a change to the handler.independent, capCAP service kind putting eleven model providers behind one API
- @shahid.la/cds-db-nlquery-mcp@shahid.la/cds-db-nlquery-mcpMCP server that answers plain-English questions against the entities in db/schema.cds — it discovers the schema, generates CQN-backed SQL with real joins, and returns rows.independent, capMCP server answering plain-English questions against a CDS schema
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
History in the atlas
- First seen.
For your agent
- Ref
artifact:geertjanklaps-cds-toon-ai-protocol-adapter- JSON
- /artifacts/geertjanklaps-cds-toon-ai-protocol-adapter.json
- MCP
- Connecting an agent