Welcome to API Portal
Kickstart your API journey!
OpenAI trained the GPT-35-Turbo and GPT-4 models to accept input formatted as a conversation. The messages parameter takes an array of message objects with a conversation organized by role. When using the Python API a list of dictionaries is used.
The format of a basic Chat Completion is as follows:
{"role": "system", "content": "Provide some context and/or instructions to the model"},
{"role": "user", "content": "The users messages goes here"}
A conversation with one example answer followed by a question would look like:
{"role": "system", "content": "Provide some context and/or instructions to the model."},
{"role": "user", "content": "Example question goes here."},
{"role": "assistant", "content": "Example answer goes here."},
{"role": "user", "content": "First question/message for the model to actually respond to."}
POST /your-api-url
Content-Type: application/json
Ocp-Apim-Subscription-Key: [your api subscription key]
{
"messages": [
{
"role": "system",
"content": "You are an AI assistant that helps [your context]"
},
{
"role": "user",
"content": "[your question or request]"
}],
"temperature": 0.2,
"top_p": 0.95,
"max_tokens": 100
}
What are "temperature" and "top_p" parameters for?https://learn.microsoft.com/en-us/answers/questions/1313865/recommended-openai-temperature-and-top-p
What is the "system" role or prompt for?https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/chatgpt?pivots=programming-language-chat-completions#system-role
How to make REST API call in Python?https://hackernoon.com/using-a-rest-api-with-python
Sample HTTP response for "Chat Completion API"https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/chatgpt?pivots=programming-language-chat-completions#output
How to generate embeddinghttps://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/embeddings
Powered by Azure