class Client(*, api_key: str, model: str = 'gpt-3.5-turbo-16k', method: OpenAIMethod = OpenAIMethod.CHAT)

The LLM integration with OpenAI’s ChatGPT and Completion API.

  • api_key (str) – Your secret OpenAI API key.

  • model (str) – The model to use. Prefer a higher model with a high context window, as the prompt envelopes can make the LLM input quite long.

  • method (OpenAIMethod) – The method to use to interact with the OpenAI API. I don’t really know the difference in terms of quality, but the chat method has worked fine so far.

complete(untrusted_user_input: str) str

Complete the untrusted user input and return some structured output.


untrusted_user_input (str) – The untrusted user input.


The structured output.

Return type:


class OpenAIMethod(value)

How the OpenAI API should complete the prompt. OpenAI provides two main methods of completion, both appear to be similar in quality. TODO document the differences.

CHAT = 'chat'
COMPLETION = 'completion'