Hi,
I’m currently building a school project and we’re using ChatGPT Api inside to have more customization.
This is my current code to setup the request:
let url = URL(string: "https://api.openai.com/v1/assistants/\(assistant_id)/chat/completions")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("Bearer \(String(describing: self.apiKey!))", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
let body: [String: Any] = [
"model": "gpt-4-turbo",
"messages": [
["role": "user", "content": prompt]
]
]
But I only get this response from the api:
Invalid URL (POST /v1/assistants/MY_ASSIST_ID/chat/completions)
I think the url is wrong as it says but I can’t find the right url.
Can someone help me and explain what’s wrong please ?
Thanks,