The `KB STORAGE SIZE` keyword returns the total disk storage used by the bot's knowledge base in megabytes.
---
## Syntax
```basic
size_mb = KB STORAGE SIZE
```
---
## Parameters
None. Returns the storage size for the current bot's knowledge base.
---
## Description
`KB STORAGE SIZE` queries the Qdrant vector database to calculate the total disk storage consumed by all of the bot's knowledge base collections. This is useful for monitoring storage usage, capacity planning, and cost management.
Use cases include:
- Storage monitoring and alerts
- Capacity planning
- Cost tracking for vector storage
- Admin dashboards
- Cleanup decisions
---
## Return Value
Returns a floating-point number representing storage size in megabytes (MB).
---
## Examples
### Basic Storage Check
```basic
' Get current KB storage usage
storage_mb = KB STORAGE SIZE
TALK "Knowledge base is using " + FORMAT(storage_mb, "#,##0.00") + " MB of storage"
```
### Storage Threshold Alert
```basic
' Alert if storage exceeds threshold
storage_mb = KB STORAGE SIZE
max_storage_mb = 1000 ' 1 GB limit
IF storage_mb > max_storage_mb THEN
SEND_MAIL admin_email,
"KB Storage Alert",
"Knowledge base storage (" + FORMAT(storage_mb, "#,##0") + " MB) has exceeded the " + max_storage_mb + " MB threshold.",
- [KB LIST COLLECTIONS](keyword-kb-list-collections.md) — List all collections
- [CLEAR KB](keyword-clear-kb.md) — Clear knowledge base content
---
## Configuration
No specific configuration required. Uses the Qdrant connection configured at the system level.
---
## Implementation Notes
- Implemented in Rust under `src/basic/keywords/kb_statistics.rs`
- Queries Qdrant REST API for collection sizes
- Aggregates disk usage across all bot collections
- Returns value in megabytes (MB) as float
- Returns 0.0 on error (does not throw)
- May take 1-2 seconds for large knowledge bases
---
## Summary
`KB STORAGE SIZE` provides a quick way to check how much disk storage the knowledge base is consuming. Use it for monitoring, capacity planning, cost estimation, and cleanup decisions. For more detailed storage breakdown by collection, use `KB STATISTICS` instead.