@@ -163,22 +163,25 @@ print() -- print a newline
163163
164164## Documentation
165165
166+ ``` lua
167+ local openai = require (" openai" )
168+ ```
169+
166170The ` openai ` module returns a table with the following fields:
167171
168- - ` OpenAI ` : A client for sending requests to the OpenAI API.
172+ - ` OpenAI ` : A class function to create a new OpenAI client instance
169173- ` new ` : An alias to ` OpenAI ` to create a new instance of the OpenAI client
170- - ` ChatSession ` : A class for managing chat sessions and history with the OpenAI API.
171- - ` VERSION = "1.5.0" ` : The current version of the library
174+ - ` VERSION = "1.7.0" ` : The current version of the library
172175
173176### Classes
174177
175178#### OpenAI
176179
177- This class initializes a new OpenAI API client.
180+ The OpenAI HTTP client.
178181
179182##### ` new(api_key, config) `
180183
181- Constructor for the OpenAI client.
184+ Constructor to create a new client instance
182185
183186- ` api_key ` : Your OpenAI API key.
184187- ` config ` : An optional table of configuration options, with the following shape:
@@ -193,9 +196,10 @@ local client = openai.new(api_key)
193196##### ` client:new_chat_session(...) `
194197
195198Creates a new [ ChatSession] ( #chatsession ) instance. A chat session is an
196- abstraction over the chat completions API that stores the chat history. You can
197- append new messages to the history and request completions to be generated from
198- it. By default, the completion is appended to the history.
199+ abstraction over the chat completions API that stores the chat history, and
200+ other state like model choice and available tools. You can append new messages
201+ to the history and request completions to be generated from it. By default, the
202+ completion is appended to the history.
199203
200204##### ` client:new_responses_chat_session(...) `
201205
@@ -222,6 +226,8 @@ will be decoded from JSON if possible, otherwise the raw string is returned.
222226
223227##### ` client:chat(messages, opts, chunk_callback) `
224228
229+ ** Deprecated**
230+
225231Legacy alias for ` create_chat_completion ` with filtered streaming chunks. When streaming, the callback receives parsed chunks in the format ` {content = "...", index = ...} ` instead of raw event objects.
226232
227233##### ` client:completion(prompt, opts) `
0 commit comments