Skip to content

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 ​

OptionDefaultMeaning
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)
keepRecent2Latest messages kept as plain text
marksfalseColour 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>.