Hi Noam and David.
KIM_KEY_STRING_LENGTH is a constant that is defined and is a valid max length for most strings that the KIM API deals with.
However, this is not the case for the string returned by the KIM_API_get_model_kim_str() routine. This string can be of arbitrary length (in principal). It is a verbatim copy of the Model's ".kim" file (including comments, blank lines, etc.)
In the future, this routine will be deprecated in favor of a more programatic interface to access the content of the Model's ".kim" file. Thus, KIM_API_get_model_kim_str() should be viewed as a stop-gap measure to provide some access to this information (albeit inconvenient access). This means that the use of KIM_API_get_model_kim_str() is discouraged. However, it does make sense that, while the function is in the KIM API, the KIM API provide access to the length of the string that will be returned by a call to KIM_API_get_model_kim_str().
I can easily add such a function. I've put it on my todo list and I'll expect to include this in the next release of the KIM API.