Difficulties in Integrating the OpenAI API Assistant into My Application

The example in your image did use chat completion endpoint, nothing to do with assistant api.

To learn how to use assistant api you need to look at official docs carefully or search some examples like this:

If you really created an assistant and get assistant_id(asst_xxxx), you need to create a thread, append message(user input) to that thread, and create a run assigning your assistant_id, then do a loop to wait(pooling with some sleep time) the run status to complete then get the assistant response from message list. You may want assistant to streaming result, which a bit more complicated, and need search related examples.

And VERY import, you leak your openai apikey on above image which is VERY bad, delete that key and create a new one instead and don’t leak it again to public, or anyone can use your key to call api and you will pay for them.

3 Likes