> ## Documentation Index
> Fetch the complete documentation index at: https://portkey-docs-add-third-party-integration-issues-fixes.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# MindsDb

> Integrate MindsDB with Portkey to build enterprise-grade AI use-cases

MindsDB connects to various data sources and LLMs, bringing data and AI together for easy AI automation.

With Portkey, you can run MindsDB AI systems with 250+ LLMs and implement enterprise-grade features like [LLM observability](/product/observability), [caching](/product/ai-gateway/cache-simple-and-semantic), [advanced routing](/product/ai-gateway), and more to build production-grade MindsDB AI apps.

## Prerequisites

Before proceeding, ensure the following prerequisites are met:

1. Install MindsDB locally via [Docker](https://docs.mindsdb.com/setup/self-hosted/docker) or [Docker Desktop](https://docs.mindsdb.com/setup/self-hosted/docker-desktop).
2. To use Portkey within MindsDB, install the required dependencies following [this instruction](https://docs.mindsdb.com/setup/self-hosted/docker#install-dependencies).
3. Obtain the [Portkey API key](https://app.portkey.ai) required to deploy and use Portkey within MindsDB.

## Setup

<Steps>
  <Step title="Create an AI engine from the Portkey handler">
    * You can pass all the parameters that are supported by Portkey inside the `USING` clause.
    * Check out the Portkey handler implementation [here](https://github.com/mindsdb/mindsdb/tree/main/mindsdb/integrations/handlers/portkey_handler).

    <CodeGroup>
      ```sql Using Portkey's Configs theme={null}
      CREATE ML_ENGINE portkey_engine
      FROM portkey
      USING
          portkey_api_key = '{PORTKEY_API_KEY}',
          config = '{PORTKEY_CONFIG_ID}';
      ```

      ```sql Using Portkey's Virtual Keys theme={null}
      CREATE ML_ENGINE portkey_engine
      FROM portkey
      USING
          portkey_api_key = '{PORTKEY_API_KEY}',
          virtual_key = '{YOUR_PROVIDER_VIRTUAL_KEY}', -- choose from 1600+ provider
          provider = '{PROVIDER_NAME}'; --- ex- openai, anthropic, bedrock, etc.
      ```
    </CodeGroup>

    <Note>
      Portkey's configs are a powerful way to build robust AI systems. You can use them to implement [guardrails](/product/guardrails), [caching](/product/ai-gateway/cache-simple-and-semantic), [conditional routing](/product/ai-gateway/conditional-routing) and much more in your AI apps.
    </Note>
  </Step>

  <Step title="Create a model with portkey_engine">
    * You can pass all the parameters supported by Portkey Chat completions here inside the `USING` clause.

    ```sql Create Portkey Model theme={null}
    CREATE MODEL portkey_model
    PREDICT answer
    USING
          engine = 'portkey_engine',
          temperature = 0.2;
    ```

    <Note>
      Learn more about the supported paramteres in Chat Completions [here](https://portkey.ai/docs/api-reference/inference-api/chat).
    </Note>
  </Step>

  <Step title="Query the model to get predictions">
    ```sql Query Portkey Model theme={null}
    SELECT question, answer
    FROM portkey_model
    WHERE question = 'Where is Stockholm located?';
    ```

    Here is the output:

    ```md Output theme={null}
    +-----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
    | 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. |
    +-----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
    ```
  </Step>
</Steps>

### Next Steps

Check out the [MindsDB Use Cases](https://docs.mindsdb.com/use-cases/overview) page to see more examples.
