According to OpenAI themselves, the main way to limit the characters of the completion, is by using the “Max tokens” setting. This is shared between the prompts and completion, so a bit of trial and error is required.
Here are the three ways the OpenAI developer article mention:
1. Reduce Max Tokens
The main way to control the length of your completion is with the max tokens setting. In the Playground, this setting is the “Response Length.” These requests can use up to 2,049 tokens, shared between prompt and completion.
2. Provide Instructions
Provide instructions to generate the desired output length, such as a specific number of items in a list. This works especially well with the instruct series.
3. Give Examples
Add examples of a specific length
The API is great at recognizing patterns and will consider the length of examples given when generating text. By providing an example, or multiple examples, with the desired output length, you can give needed context about the expected length.
For more information, see the original article linked above.