Skip to content

Add context field to OpenRouter, MistralAI, and OpenAI models#2653

Open
costajohnt wants to merge 2 commits intoHeyPuter:mainfrom
costajohnt:fix/openrouter-context-window
Open

Add context field to OpenRouter, MistralAI, and OpenAI models#2653
costajohnt wants to merge 2 commits intoHeyPuter:mainfrom
costajohnt:fix/openrouter-context-window

Conversation

@costajohnt
Copy link

@costajohnt costajohnt commented Mar 12, 2026

Summary

  • Map context_length from OpenRouter's API response to the context field in the model list, matching the pattern used by all other providers
  • Add context field to all 16 MistralAI hardcoded model definitions
  • Add context field to all 27 OpenAI hardcoded model definitions

All 9 providers now consistently expose context window sizes via the context field.

Context values by provider family:

  • MistralAI: 32k–262k depending on model (matches documented context windows)
  • OpenAI GPT series: 128k (GPT-4o, GPT-5.x)
  • OpenAI o-series: 128k (o1-mini) or 200k (o1, o3, o4-mini)
  • OpenAI GPT-4.1: 1,047,576
  • OpenAI GPT-5.4: 1,050,000

Closes #2347

Test plan

  • Verify OpenRouter models include context in the model list API response
  • Verify MistralAI models include context field
  • Verify OpenAI models include context field
  • Confirm no regressions for other providers (Claude, DeepSeek, Gemini, Groq, TogetherAI, XAI already had context)

OpenRouter's API returns context_length for each model, but it was not
being mapped to the context field in the model list response. This
caused the context window size to be missing for all OpenRouter models.

Closes HeyPuter#2347
@CLAassistant
Copy link

CLAassistant commented Mar 12, 2026

CLA assistant check
All committers have signed the CLA.

@costajohnt costajohnt marked this pull request as ready for review March 12, 2026 04:25
@ProgrammerIn-wonderland
Copy link
Collaborator

we should probably support this "context" field in more models too

Addresses reviewer feedback to support the context field in more
providers. All 9 providers now consistently expose context window
sizes via the context field.

- MistralAI: 16 models (context matches known window sizes)
- OpenAI: 27 models (128k for GPT series, 200k for o-series,
  1M+ for GPT-4.1 and GPT-5.4)
@costajohnt costajohnt changed the title Map context_length for OpenRouter models Add context field to OpenRouter, MistralAI, and OpenAI models Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing context window data for openrouter models

3 participants