Use own chatgpt API
# 🤝help
Hello, sorry to bother with the newbie question. I try to use code to link my own OpenAI but it cant generate a response. Is there someting wrong this the workflow (like let the code capture the question) or with the code. Thank you so much for your time.

Hi try this
`const apiKey = env.gpt_key; const {data} = await"", { "model": "gpt-3.5-turbo-0301", "messages": [{"role": "user", "content": event.preview}] }, { headers: {'Authorization':
Bearer ${apiKey}
}}); workflow.chatGPTResponse = data.choices[0].message.content;`
of course put your api key
but use event.preview in "content" and tell me
event.preview refers to the last input placed
also try ghatgpt 3.5 first
@green-answer-87939 I think your code is missing the "question" variable
Do i need to create a questin variable as event.preview already save the user last input. e.g. const question = workflow.userquestion; I tried use event.preview in "content" and replace it with a question variable. neither of them works.
what do you mean by neither of them works?
what are you trying to achieve?
event.preview holds the last input from the user side
did you try sending a static value? just to make sure that the rest of the code is correct?
also are you sure that this "data.choices[0].message.content" works?
is this code generated by chatGPT?
sorry for so many questions 🙈