JavaScript SDK Overview
The GLYPH JavaScript SDK provides a token-efficient serialization format optimized for LLM communication. It reduces token usage by 40-60% compared to JSON while maintaining full type safety and schema validation.Installation
Install the GLYPH JavaScript SDK using your preferred package manager:Requirements
- Node.js >= 18.0.0
- TypeScript >= 5.0 (optional, for TypeScript projects)
TypeScript Support
The SDK is written in TypeScript and includes full type definitions out of the box:Quick Start
Here’s a complete example showing the core workflow:Token Savings
GLYPH achieves significant token savings over JSON:| Data Type | Token Savings |
|---|---|
| LLM messages | 40% |
| Tool calls | 42% |
| Conversations (25 msgs) | 49% |
| Search results (50 rows) | 52% |
| Batch tool results | 62% |
Encoding Modes
GLYPH supports multiple encoding modes optimized for different use cases:Packed Mode
Positional encoding with optional bitmap compression:Tabular Mode
Optimized for lists of structs:Struct Mode
Named field encoding (v1 compatible):Core Concepts
GValue
The universal value container for all GLYPH data. See Core Types for details.Schema
Defines types, fields, and encoding rules. See Core Types for details.Parsing
Converts GLYPH format strings back to GValue objects. See Parsing for details.Streaming
Incremental validation for real-time LLM tool calls. See Streaming for details.API Organization
The JavaScript SDK is organized into several modules:- Core: GValue, Schema, type constructors
- JSON: JSON conversion utilities
- Emit: GLYPH format encoders
- Parse: GLYPH format parsers
- Stream: Streaming transport (GS1) and validation
- Patch: Delta encoding for updates
- Loose: Schema-optional mode
Next Steps
Core Types
Learn about GValue, Schema, and type constructors
Parsing
Parse GLYPH format strings
Streaming
Real-time validation and GS1 transport
GitHub
View source and examples