API doesn' t work with a model made bij client

Hello, I have made a chat function on a webpage. This works perfect with the standard model: gpt-4 works also with gpt-3.5-turbo.
The client has made her own model: Decoration-Color-Visualizer.
But when I change the value in the javascript it gives an error.

function sendMessageToOpenAI(message) {
const apiKey = ‘sk-YgAblablabla’;
const url = ‘https : // api. openai. com/ v1/ chat/ completions’;

const data = {
    model: 'gpt-4',  // Je kunt hier ook 'gpt-3.5-turbo' of Decoration-Color-Visualizer
    messages: [
        { role: 'system', content: 'You are a helpful assistant.' },
        { role: 'user', content: message }
    ],
    max_tokens: 150,
    temperature: 0.7
};

fetch(url, {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${apiKey}`
    },
    body: JSON.stringify(data)
})
.then(response => {
    if (!response.ok) {
        throw new Error(`HTTP Error: ${response.status}`);
    }
    return response.json();
})
.then(responseData => {
    const assistantMessage = responseData.choices[0].message.content;

    // Voeg het antwoord van de AI toe aan de chatbox
    const assistantMessageElement = document.createElement('div');
    assistantMessageElement.textContent = assistantMessage;
    assistantMessageElement.className = 'assistant-message';
    document.getElementById('chat-box').appendChild(assistantMessageElement);
    document.getElementById('chat-box').scrollTop = document.getElementById('chat-box').scrollHeight;
})
.catch(error => {
    console.error('Error:', error);
    const errorMessageElement = document.createElement('div');
    errorMessageElement.textContent = `Error: ${error.message}`;
    errorMessageElement.className = 'error-message';
    document.getElementById('chat-box').appendChild(errorMessageElement);
    document.getElementById('chat-box').scrollTop = document.getElementById('chat-box').scrollHeight;
});

}
Could somebody help me, with some tips?

Thanks in advance.
Brian

Is it an OpenAI fine-tuned model or something else? More details?

Thank you you for the respons.
I am sorry I haven´t given enough info.

If I go to Explore GTPs in the left column ( https: //chatgpt .com /gpts) and then type:
Decoration-Color-Visualizer
you can find her work. I don’t know if it is called a fine tuned model.
But it works perfect on the webpage of openai . com but doesn’t when I use the javascript function.

I hope this helps.

1 Like

Ah, gotcha.

Custom GPTs are only available in the ChatGPT ecosystem. You can’t access them via the API.

You can try to recreate the Custom GPT with the Assistants API.

Hello,
Not the respons I was hoping for…
But I am now asking Chatgtp how do I recreate the Custom GPT with the Assistants API…

Thank you for your answer.
Brian

1 Like

Yeah, it’s not too difficult, but there’s likely a custom prompt on ChatGPT that you won’t be able to replicate exactly. Do come back to let us know how you make out, though…

The Cookbook might also be useful…