File tree Expand file tree Collapse file tree 1 file changed +3
-0
lines changed
src/main/kotlin/com/cjcrafter/openai/chat Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change @@ -31,11 +31,13 @@ import java.util.function.Consumer
3131 * to the API dashboard, where you can find your unique API key. Copy and store it securely.
3232 *
3333 * @property apiKey Your OpenAI API key. It starts with `"sk-"` (without the quotes).
34+ * @property organization If you belong to multiple organizations, specify which one to use (else `null`).
3435 * @property client Controls proxies, timeouts, etc.
3536 * @constructor Create a ChatBot for responding to requests.
3637 */
3738class ChatBot @JvmOverloads constructor(
3839 private val apiKey : String ,
40+ private val organization : String? = null ,
3941 private val client : OkHttpClient = OkHttpClient ()
4042) {
4143
@@ -51,6 +53,7 @@ class ChatBot @JvmOverloads constructor(
5153 .url(" https://api.openai.com/v1/chat/completions" )
5254 .addHeader(" Content-Type" , " application/json" )
5355 .addHeader(" Authorization" , " Bearer $apiKey " )
56+ .apply { if (organization != null ) addHeader(" OpenAI-Organization" , organization) }
5457 .post(body).build()
5558 }
5659
You can’t perform that action at this time.
0 commit comments