Documentation

Quickstart

Step-by-step tutorial for using the Konko API to generate text

Generate your first text response


Tutorial objective: generate a summary of the book "The Foundation" by Isaac Asimov using meta-llama/llama-2-13b via two methods:

  • Method #1: Konko AI's Python SDK
  • Method #2: HTTP

No prior knowledge about Konko AI required. Estimated time to follow along end-to-end is less than 5 minutes


🚧

To follow along you will need a Konko API key

You may request a Konko API key at [email protected] or in our discord


Method #1: Python SDK


Step #1: Access & SDK Installation

You must first follow the Setup Access & SDK guide.


Step #2: Check Available Models for Use

  1. Run the following Python commands to retrieve a simple list of currently active models
import konko

# Retrieve the IDs of all models hosted by Konko and recommended from OpenAI
models = konko.models.list()

for item in models.data:
     print(item.id)

Response

codellama/codellama-13b-instruct
codellama/codellama-34b
codellama/codellama-34b-instruct
codellama/codellama-34b-python
codellama/codellama-7b-instruct
meta-llama/llama-2-13b
meta-llama/llama-2-13b-chat
meta-llama/llama-2-70b
meta-llama/llama-2-70b-chat
.....

Step #3: Generate Text Using an LLM

  1. Run the following Python commands to generate a completion from the Konko provided model: meta-llama/llama-2-13b
import konko

response = konko.completions.create(
    model="meta-llama/llama-2-13b",
    prompt="Summarize the Foundation by Isaac Asimov",
  	max_tokens=500
    
)

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
          )

Method #2: HTTP


You can recreate the above example in any popular programming language by following the directions on our interactive API Reference docs.


Recommended Next Steps


Now that you've setup the Konko AI API and know the basics of how to generate text, we recommend you...

  1. Familiarize yourself with our documentation on Accessing Models to help you decide which LLMs to evaluate and to guide you in crafting effective prompts for optimal results.
  2. Transition seamlessly from OpenAI to Konko with minimal code changes. Learn more about this in Switch OpenAI Apps to Konko API.
  3. Once you're ready to move to production, review Moving to Production for next steps and FAQ.