From 746213f5d169f1f47d320ee73446812d9ce5cd38 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Mon, 15 Jan 2024 09:53:57 -0800 Subject: [PATCH] (test) proxy - add JS OpenAI test --- litellm/proxy/tests/test_openai_js.js | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 litellm/proxy/tests/test_openai_js.js diff --git a/litellm/proxy/tests/test_openai_js.js b/litellm/proxy/tests/test_openai_js.js new file mode 100644 index 00000000000..538e6ee7e53 --- /dev/null +++ b/litellm/proxy/tests/test_openai_js.js @@ -0,0 +1,31 @@ +const openai = require('openai'); + +// set DEBUG=true in env +process.env.DEBUG=false; +async function runOpenAI() { + const client = new openai.OpenAI({ + apiKey: 'your_api_key_here', + baseURL: 'http://0.0.0.0:8000' + }); + + try { + const response = await client.chat.completions.create({ + model: 'azure-gpt-3.5', + messages: [ + { + role: 'user', + content: 'this is a test request, write a short poem'.repeat(2000), + }, + ], + }); + + console.log(response); + } catch (error) { + console.log("got this exception from server"); + console.error(error); + console.log("done with exception from proxy"); + } +} + +// Call the asynchronous function +runOpenAI(); \ No newline at end of file