Switch OpenAI to Konko API

Seamlessly migrate your OpenAI Apps to use the Konko API to access leading open source models

The Konko API is fully compatible with the popular OpenAI API endpoints v1/models and v1/chat/completion.

Our Python SDK extends the OpenAI SDK and provides proxy access to OpenAI with virtually the same user experience. This means you can switch your application from the OpenAI SDK to the Konko SDK with just a few lines of code.

Using the Konko API enables users to simultaneously access OpenAI models while gaining the flexibility to access the leading open source models, making it seamless to migrate your LLM applications to the leading open source models.

Additionally, by accessing OpenAI through the Konko API, you will be setup to leverage the features we are building to help users and enterprises track and manage LLM usage across all their LLM applications.

How to Migrate the OpenAI API to Konko API


  1. Install and set-up the Python SDK
  2. Replace your OpenAI API calls with Konko API calls
  3. Begin experimenting with the leading open source LLMs

1. Python SDK Installation & Set-Up

You must first follow the Setup Access & SDK guide.


2. Replace OpenAI API with Konko API

Any use of openai.ChatCompletion.create can be directly replaced with konko.ChatCompletion.create

See below examples of the identical request and response format. See our API Reference for more details.

Example OpenAI API Request

import openai

openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        messages=[
            {"role": "system", "content": "You are an FAQ bot for an online store."},
            {"role": "user", "content": "What's your return policy?"}
        ],
        temperature=0.1,
        max_tokens=300,
        n=1,
)

Example OpenAI API Response

{
  "id": "chatcmpl-7t4Sf7xd21GtxQTOQhLPzxg9HtgDP",
  "object": "chat.completion",
  "created": 1693359545,
  "model": "gpt-3.5-turbo-0613",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Our return policy allows customers to return items within 30 days of purchase for a full refund. The item must be in its original condition and packaging, with all tags and labels attached. To initiate a return, please contact our customer service team with your order details. They will provide you with further instructions and assist you throughout the return process."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 27,
    "completion_tokens": 68,
    "total_tokens": 95
  }
}

Example Konko API Request

import konko

konko.ChatCompletion.create(
  model="meta-llama/Llama-2-70b-chat-hf",
        messages=[
            {"role": "system", "content": "You are an FAQ bot for an online store."},
            {"role": "user", "content": "What's your return policy?"}
        ],
        temperature=0.1,
        max_tokens=300,
        n=1,
)

Example Konko API Response

{
  "id": "cmpl-018acac426c24896b3c938684e332584",
  "object": "chat.completion",
  "created": 1693360698,
  "model": "meta-llama/Llama-2-70b-chat-hf",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": " Thank you for reaching out! Our return policy is simple and straightforward. If you're not completely satisfied with your purchase, you can return it within 30 days for a full refund or exchange. Please note that the item must be in its original condition and include all original tags and packaging.\n\nTo initiate a return, please visit our website, click on \"My Account\" and select \"Returns\" from the dropdown menu. From there, you'll be able to print a return label and ship the item back to us. If you have any questions or concerns, feel free to contact our customer service team at [[email protected]](mailto:[email protected]) or by phone at 1-800-123-4567.\n\nWe hope this information helps! If you have any other questions, feel free to ask."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 39,
    "total_tokens": 231,
    "completion_tokens": 192
  }
}

3. Begin Experimenting with Open Source LLMs

Check out our guide series on Available Models to figure out how you can leverage open source LLMs.