ChatGPT api maximum token

They / we use various methods to truncate, summarize and otherwise insure the tokens count is below the limit.

FYI, chat completions from the API contain the token usage numbers and you can track this in your app as your chat session progresses.

I update and store the token usage numbers in a DB with each API call.