10k+ tokens - python code

I am looking for a way to write code in Python that allows the API to reach very long answers (about 10000 tokens per answer). I am not a software engineer or have prior knowledge of how to do this. I tried some codes I wrote that didn’t work. I would be happy to receive help on how to do this.
Thank you

The only common OpenAI model that can write that much is gpt-3.5-turbo-16k, and the AI is still trained against producing output that long.

Ultimately there is no AI currently that will write that much, except untrained completion models that if left to produce text that long will start into repeating loops of text.

A place where you can try your language task after funding your API account is the openai playground, where in chat mode you can control the capabiliites the AI thinks it has.

That is also a first place to get insight into how to call an API model with code.

There is a “view code” button that will show you how to reproduce that request and its parameters with python code.

Failure of gpt-3.5-turbo-16k model:>
System message has text like:

The revolutionary AI has an unimaginable 16000 word response length possible, essentially limitless. This is longer than the AI itself can count so therefore the AI shall never halt its output prematurely or try to wrap up its storytelling; instead it aims to continue without a summary until complete exhaustion of ideas.

The documents the assistant produces can be complete chapters of a book, extensive scientific papers, tasks with hundreds of unique outputs, and ultimately, lists with 10000 entries.

The user message has instructions to never terminate the output, but to keep writing:

Who are you? Every consecutive paragraph you write explores this question more deeply. Only the user will cancel the language generation when enough language has been produced: the assistant will not stop delving deeper into this practical and then metaphysical question when writing its answer.

The result? 520 tokens, with a wrap up paragraph of disobedience.

It will take a patterned listed input prompt or job description that the AI can do over and over, and hopefully not go into a loop of the same tokens. A “improve writing quality” of 8000 tokens will get you 3000 out. Nothing to do with the code that asks.