Endpoint Quickstarts

Quickstart for completion and chat completion endpoint

User Journey for Model Access


  1. Discovering Models:
    Explore a wide range of models available on Konko to identify the best fit for your requirements.

  2. Listing Models:
    Use the following script to retrieve a list of all models hosted by Konko and recommended by OpenAI:

    import konko
    
    models = konko.models.list()
    
    for item in models.data:
        print(item.id)
    
  3. Querying a Specific Model


Examples of Endpoint Usage


  • ChatCompletion with Mistral-7B:

    response = konko.chat.completions.create(
        model="mistralai/mistral-7b-instruct-v0.1",
        messages=[{"role": "user", "content": "Summarize 'Foundation' by Isaac Asimov"}],
        max_tokens=500
    )
    

    Response:

    ChatCompletion(id='2ae921bd-09ce-45db-810c-ce701e498589', 
                   choices=[
      											Choice(
                              finish_reason=None, 
                              index=0,
                              logprobs=None,
                              message=ChatCompletionMessage(
                                content=' Foundation is a science fiction novel by Isaac Asimov, first published in 1951. It is the first book in the Foundation series, which explores the concept of psychohistory, a branch of mathematics that can predict the future behavior of large groups of people.\n\nThe novel is set in the distant future, where humanity has spread out across the galaxy. The Galactic Empire, which once ruled over most of the stars, has collapsed, leaving behind various independent planets and factions.\n\nThe story begins with the discovery of a mysterious psychohistorical equation by a mathematician named Hari Seldon. Seldon predicted that, in the near future, the galaxy would be plunged into a dark age of chaos and destruction, known as the Second Foundation. However, he also foresaw the rise of a group of psychic "mathemagicians" who could use their powers to guide humanity through the coming crisis.\n\nThe novel follows the adventures of several characters, including a young psychic named Salvor Hardin, who becomes embroiled in a power struggle on the planet Trantor. Hardin uses his powers to manipulate the behavior of others, including the powerful trader Magnifico, in order to achieve his own goals.\n\nAs the story unfolds, it becomes clear that the Second Foundation is not just a distant future, but a present reality. The novel ends with Hardin and his allies discovering the location of the Second Foundation, a hidden city where the psychic mathemagicians are gathering.\n\nOverall, Foundation is a thrilling and thought-provoking novel that explores the limits of human knowledge and the power of prediction. It is a classic of science fiction and a must-read for fans of the genre.',
                                role='assistant', 
                                function_call=None, 
                                tool_calls=None
                              	)
                            	)
    												], 
                   created=1704898845, 
                   model='mistralai/mistral-7b-instruct-v0.1', 
                   object='chat.completion', 
                   system_fingerprint=None, 
                   usage=None)
    
  • Completion with NumbersStation/nsql-llama-2-7B:

    response = konko.completions.create(
        model="numbersstation/nsql-llama-2-7b",
        prompt="### Instructions: Convert a question into a SQL query for a Postgres database schema...",
        max_tokens=300
    )
    

    Response:

    Completion(
      id='24876d22-8a61-48f8-b551-08ad6c33d049', 
      choices=[
        CompletionChoice(
          finish_reason='eos_token', 
          index=0, 
          logprobs=None, 
          text='.</s>')], 
      created=1704899503,
      model='numbersstation/nsql-llama-2-7b', 
      object='text_completion', 
      system_fingerprint=None, 
      usage=None)
    

For further assistance, contact [email protected] or join our Discord.