Repository navigation
API Reference WebSocket Events
Sudharsan Selvaraj edited this page Jul 20, 2026
·
1 revision
The WS /ws/generate endpoint streams a greedy autoregressive generation in real-time.
The protocol uses a strict JSON framing system. The client sends one configuration frame, and the server responds with a stream of data frames, ending with a done frame.
{
"prompt": "Name one primary color.",
"max_new_tokens": 40,
"top_k": 10,
"trace": true,
"record_trace": false
}-
trace: If true, includes theop_catalogandlayer_statsin the response. Required for TokenPrint's UI. -
record_trace: If true, saves the entire stream to disk on the backend for later replay.
{
"type": "meta",
"model": "Qwen/Qwen2.5-0.5B-Instruct",
"architecture": "qwen2",
"num_layers": 24,
"prompt_tokens": ["Name", "one", ...],
"uses_kv_cache": true,
"op_catalog": [
{
"index": 0,
"op_key": "embedding",
"label": "Token Embedding",
"param_count": 136134656
}
// ... 243 operations
]
}{
"type": "token",
"step": 0,
"phase": "prefill",
"n_positions": 5,
"cache_len": 0,
"chosen": { "id": 6893, "text": "Red", "logprob": -0.04 },
"topk": [
{ "id": 6893, "text": "Red", "prob": 0.957 },
{ "id": 124, "text": "Blue", "prob": 0.021 }
],
"layer_stats": [0.45, 1.2, 0.8, ...] // Mean activation magnitude per layer
}{
"type": "done",
"generated_text": "Red",
"total_steps": 2
}| Previous | Home | Next |
|---|---|---|
| REST API | Home | Data Models |
TokenPrint Wiki | Home | Getting Started | User Guide | Concepts | Architecture | API | GitHub
TokenPrint is an interactive 3D visualization platform for exploring transformer architectures, tensors, and real-time LLM inference.
- User Guide
- Architecture Explorer
- Live Inference
- Tensor Inspector
- Camera Controls
- HUD
- Timeline
- Scene Navigation
- Transformer Concepts
- Tokenization
- Embeddings
- Positional Encoding
- RoPE
- Multi-Head Attention
- KV Cache
- LayerNorm
- Feed Forward Network
- Residual Connections
- Logits
- Softmax
- Sampling
- Autoregressive Generation
- Visualization System
- Scene Graph
- Geometry
- Materials
- Animation System
- Color Mapping
- Camera System
- Interaction Model
- Architecture
- Overall Architecture
- Frontend
- Backend
- WebSocket Protocol
- Data Pipeline
- Renderer
- Event System