| Name | Type | Description |
|---|---|---|
modelname* | str | The modelname we want to know the context size for. |
Return the maximum input context size for a model.
Prefers the model's profile (max_input_tokens) and falls back to a
mapping of legacy models that have no profile.
Now returns max_input_tokens from the model profile, which is the
input context window. Earlier releases returned a hand-maintained
number that for some newer models (e.g. gpt-5) reflected the
total context (input + output). Callers using the result as an
input-token budget are unaffected; callers using it as a combined
input+output budget should switch to the profile fields directly.
Example:
max_tokens = openai.modelname_to_contextsize("gpt-3.5-turbo-instruct")