OpenAI API
Endpoint: POST https://api.openai.com/v1/chat/completions
curl
text
curl https://api.openai.com/v1/chat/completions -H "Authorization: Bearer $OPENAI_API_KEY" -H "Content-Type: application/json" -d '{
"model": "gpt-4o-mini",
"messages": [
{"role": "user", "content": "Give 3 REST tips in Burmese"}
]
}'JavaScript (fetch)
text
const res = await fetch('https://api.openai.com/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + process.env.OPENAI_API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-4o-mini',
messages: [{ role: 'user', content: 'Give 3 REST tips in Burmese' }]
})
});
const data = await res.json();🎯 Result{ "choices": [{"message": {"content": "1) ... 2) ..."}}] }