Make a request
1curl https://api.AiApiGiaRe.io/v1/chat/completions \2 -H 'Content-Type: application/json' \3 -H 'Authorization: Bearer YOUR_API_KEY' \4 -d '{5 "model": "gpt-3.5-turbo",6 "messages": [{"role": "user", "content": "Say this is a test!"}],7 "temperature": 0.78}'1{2 "id": "chatcmpl-abc123",3 "object": "chat.completion",4 "created": 1677858242,5 "model": "gpt-3.5-turbo-0301",6 "usage": {7 "prompt_tokens": 13,8 "completion_tokens": 7,9 "total_tokens": 2010 },11 "choices": [12 {13 "message": {14 "role": "assistant",15 "content": "\n\nThis is a test!"16 },17 "finish_reason": "stop",18 "index": 019 }20 ]21}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.
(Code extracted to sandbox)
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:
(Code extracted to sandbox)
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.
In this example, gpt-3.5-turbo is used primarily for traditional text completion tasks. The model is also optimized for chat-based applications.