You can paste the following command into your terminal to run your first API request. Make sure to replace YOUR_API_KEY
with your secret API key.This request queries the model to complete a text prompt starting with "Say this is a test" using the gpt-3.5-turbo
model. You should receive a response similar to the following:{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677858242,
"model": "gpt-3.5-turbo-0301",
"usage": {
"prompt_tokens": 13,
"completion_tokens": 7,
"total_tokens": 20
},
"choices": [
{
"message": {
"role": "assistant",
"content": "\n\nThis is a test!"
},
"finish_reason": "stop",
"index": 0
}
]
}
Now you’ve generated your first chat completion. We can see that the finish_reason
is stop
, which means the API returned a complete response generated by the model. In the above request, we generated only one message, but you can configure the n
parameter to generate multiple message options. Modified at 2025-02-19 09:04:17