Understanding the Response

When you interact with Konko's Completion endpoint, the API returns a structured response. This section explains each component of the Completion response.

Completion Object

The Completion object is the response you get from the API, based on the input prompt provided. It includes several key elements:

  • id: A unique identifier for the completion.
  • object: Set to text_completion, indicating the type of the object.
  • created: Unix timestamp representing the creation time of the completion.
  • model: Specifies the model used to generate the completion.
  • choices: An array of completion choices, based on the n parameter. Each choice contains:
    • text: The generated text by the model.
    • index: The position of the choice in the array.
    • finish_reason: Describes why the model stopped generating text. Possible reasons include:
      • stop: The model encountered a stop sequence or a natural endpoint.
      • length: The maximum token limit was reached.
      • function_call: A function was executed within the model.
      • content_filter: Content was filtered out due to content guidelines.
      • null: Ongoing or incomplete response.
  • usage: Provides details about the tokens used in the request:
    • prompt_tokens: Number of tokens in the input prompt.
    • completion_tokens: Number of tokens in the generated completion.
    • total_tokens: Total count of tokens used in both the prompt and completion.

To access the generated text in a Python script, use:
konko_completion_phind_python.choices[0].text.

Example Response

Completion(id='82c4fe31-4d48-487c-a409-1aedb2738ac3', 
           choices=[
  									CompletionChoice
                      (
                        finish_reason=None,
                        index=0, 
                        logprobs=None, 
                        text='\nThe Foundation by Isaac Asimov is a science fiction novel that tells the story of a group of scientists who are trying to save humanity from extinction. The novel is set in the future, and it follows the story of Hari Seldon, a scientist who has developed a new field of study called psychohistory. Psychohistory is a way of predicting the future by studying the behavior of large groups of people.\nSeldon uses psychohistory to predict that the Galactic Empire will fall, and he creates a plan to save humanity from the chaos that will follow. The Foundation is a group of scientists who are working to preserve human knowledge and culture in the face of the Empire’s collapse.\nThe Foundation is a classic science fiction novel that is still relevant today. The novel explores themes of power, corruption, and the importance of knowledge. The Foundation is a must-read for any fan of science fiction.\nThe Foundation by Isaac Asimov is a science fiction novel that tells the story of a group of scientists who are trying to save humanity from extinction. The novel is set in the future, and it follows the story of Hari Seldon, a scientist who has developed a new field of study called psychohistory. Psychohistory is a way of predicting the future by studying the behavior of large groups of people.\nThe Foundation is a classic science fiction novel that is still relevant today. The novel explores themes of power, corruption, and the importance of knowledge. The Foundation is a must-read for any fan of science fiction. The Foundation by Isaac Asimov is a science fiction novel that tells the story of a group of scientists who are trying to save humanity from extinction. The novel is set in the future, and it follows the story of Hari Seldon, a scientist who has developed a new field of study called psychohistory. Psychohistory is a way of predicting the future by studying the behavior of large groups of people.\nThe Foundation is a classic science fiction novel that is still relevant today. The novel explores themes of power, corruption, and the importance of knowledge. The Foundation is a must-read for any fan of science fiction. The Foundation by Isaac Asimov is a science fiction novel that tells the story of a group of scientists who are trying'
                      )
                   ], 
           created=1704895437, 
           model='meta-llama/llama-2-13b', 
           object='text_completion', 
           system_fingerprint=None,
           usage=None
          )