Making Request

You can paste the command below into your terminal to run your first API request. Make sure to replace YOUR_API_KEY with your secret API key.

 curl https://api.whirlagi.com/v1/chat/completions \
   -H 'Content-Type: application/json' \
   -H 'Authorization: Bearer YOUR_API_KEY' \
   -d '{
   "model": "gpt-3.5-turbo",
   "messages": [{"role": "user", "content": "Say this is a test!"}],
   "temperature": 0.7
 }'

This request queries the model to complete the text that begins with the prompt " Say this is a testgpt-3.5-turbo ". 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 have generated your first chat completion. We can see finish_reasonisstop which means the API returned the full completion generated by the model. In the above request, we only generated one message, but you can set the parameter n to generate multiple message selections. In this example, gpt-3.5-turbo is more for traditional text completion tasks. The model is also optimized for chat applications.

Last updated