Skip to content

guessContextWindow

function guessContextWindow(model): number;

Defined in: core/src/context.ts:301

The context window for a model, when nothing volunteered one.

The ladder exists because the endpoints disagree about whether to tell you: OpenRouter, LM Studio and Ollama publish context_length; Anthropic and OpenAI do not. A reported number always wins; this is the floor under it.

A conservative default is the right failure: too small folds one turn early and costs a cheap call, too large hits a hard 400 mid-run.

Parameter Type
model string

number