Embeddings lists are up to 2047 strings.
ada-002 has a max of 8192 total tokens per API call. With the new 3-large models, I have yet to hit a limit at 100k+ tokens. You aren’t really saving anything by putting a whole bunch in one API call.
You can just add token count metadata to every chunk you are preparing, then just keep adding until the last one token count would exceed the accumulated limit of what you want to put in an API call.
tiktoken
indeed can count. You just encode chunks to a token list, and then measure the list length. Two lines of code.
Batch API can make any API call you can normally complete. It just has its own limits of number of calls per file and number of tokens per file and file size. If you can wait 24 hours, 50% discount.