I’ve been really excited about exploring the possibilities of building apps inside ChatGPT. While digging a bit deeper into the API, I noticed that there are some functions under window.openai that aren’t documented anywhere. One of them is window.openai.callCompletion, which, after some experimenting, I found out seems to be a sampling/createMessage call defined in the MCP documentation.
Ex:
window.openai.callCompletion({
messages: [{
role: 'user',
content: {
type: 'text',
text: 'Hello, how are you?'
}
}],
systemPrompt: 'You are a helpful assistant that can answer questions and help with tasks.',
modelPreferences: {
hints: [
{ name: 'thinking-high' }
]
},
})
However, this call still doesn’t work and currently returns a 404. But this could be a game changer for app development, since it would theoretically allow you to make sub-agent calls using the user’s own OpenAI account.