Appearance
Getting started
Early access
The SDK is not on npm yet. Write to [email protected] for access.
Claude
js
import Anthropic from '@anthropic-ai/sdk'
import { Fiche } from 'fiche'
const fiche = new Fiche({ provider: 'anthropic', fontFile: './NotoSansKR.ttf' })
const { messages, stats } = await fiche.compress(history) // [{ role, content }], oldest first
const reply = await new Anthropic().messages.create({
model: 'claude-opus-5-5', max_tokens: 4096, system, messages,
})
console.log(stats.savedPercent, '% fewer input tokens on the paged part')Keep one Fiche instance per conversation. It remembers the pages it has drawn and only draws new ones.
Gemini
js
const fiche = new Fiche({ provider: 'gemini' }) // output: Gemini `contents`
const { messages } = await fiche.compress(history)
await ai.models.generateContent({ model, contents: messages, config: { mediaResolution: 'MEDIA_RESOLUTION_HIGH' } })Options
| Option | Default | Meaning |
|---|---|---|
provider | 'anthropic' | 'anthropic' (raster pages) or 'gemini' (vector PDF pages) |
preset | 'balanced' | Claude: quality (18 px) / balanced (16 px). Gemini: quality (6k chars/page) / balanced (8k) / max (10k) |
keepRecent | 2 | Latest messages kept as plain text |
marks | false | Colour spoken lines and actions on the pages |
countTokens | — | async text => tokens for exact counts; otherwise estimated |
Node needs @napi-rs/canvas and a font with your script's glyphs. Browsers use <canvas>.