OpenAi API help please

This is my code:

  "model": "gpt-3.5-turbo",
  "messages": [
      "role": "system",
      "content": "You are an helpful assistent."
      "role": "user",
      "content": <Users Input' value>
  "temperature": 1,
  "max_tokens": 256,
  "top_p": 1,
  "frequency_penalty": 0,
  "presence_penalty": 0

I’m trying to make the user able to send messages to the ai privately and the ai respond to the person. Why dosen’t this work?

Add quotation marks “<Users Input’ value>” that should do it?

@stoicadvicor when you’re sending JSON to the AI through the API connector, you need to make sure you’re not sending JSON breaking characters (within the initial quotes.

"content": "any of the"se" } characters could break JSON"

Things to consider:

  • formatting as JSON safe operator on user inputs so that they can insert " or } without breaking JSON
  • this adds “” on either side of the string, so you need to remove these in some cases.

Examples below:

“content”: <formatted as JSON safe, don’t remove end and start quotes>
“content”: “your prompt <formatted as JSON safe, remove end and start quotes>”

Good luck!

As a rule of thumb, any user facing API call parameter should have formatted as JSON-safe put on it in the API call action.

Additionally, make sure you have the right call headers.

Read the error message if there is one and it’ll tell you what’s wrong. There’s dozens of forum posts about the OpenAI API so you can find a working example there,

Could you provide more information about any errors you’re running into. Is the API initialization providing an error? We need to see your call setup.