This documentation describes the integration of MindsDB with Portkey, an AI Gateway that allows developers to connect to All the AI models in the world with a single API. Portkey also brings in observability, caching, and other features that are useful for building production-grade AI applications.

Prerequisites

Before proceeding, ensure the following prerequisites are met:

  1. Install MindsDB locally via Docker or Docker Desktop.
  2. To use Portkey within MindsDB, install the required dependencies following this instruction.
  3. Obtain the Portkey API key required to deploy and use Portkey within MindsDB. Follow the instructions for obtaining the API key.

Setup

Create an AI engine from the Portkey handler.

You can pass all the parameters that are supported by Portkey inside the USING clause.

CREATE ML_ENGINE portkey_engine
FROM portkey
USING
    portkey_api_key = '{PORTKEY_API_KEY}', -- get this from Portkey dashboard (https://app.portkey.ai/api-keys)
    config = '{PORTKEY_CONFIG_ID}'; -- get this from Portkey dashboard (https://app.portkey.ai/configs)

Create a model using portkey_engine as an engine.

You can pass all the parameters supported by Portkey Chat completions here inside the USING clause. refer Portkey Chat completions for more details.

CREATE MODEL portkey_model
PREDICT answer
USING
      engine = 'portkey_engine',
      model = 'gpt-3.5-turbo',
      temperature = 0.2;

The integrations between Portkey and MindsDB was implemented using Portkey Python SDK.

Query the model to get predictions.

SELECT question, answer
FROM portkey_model
WHERE question = 'Where is Stockholm located?';

Here is the output:

+-----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| question                    | answer                                                                                                                                             |
+-----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| Where is Stockholm located? |  Stockholm is the capital and largest city of Sweden. It is located on Sweden's south-central east coast, where Lake Mälaren meets the Baltic Sea. |
+-----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+

Next Steps

Go to the Use Cases section to see more examples.