> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect Dify to CometAPI

> Use this guide to connect Dify to CometAPI by setting the base URL, API key, and model or provider options.

[Dify](https://dify.ai) is an open-source LLM application development platform. By connecting it to CometAPI, you can use current CometAPI model IDs inside Dify's workflow, chatbot, and agent builders.

## Prerequisites

* A CometAPI account with an active API key — [sign in to get one](https://www.cometapi.com)
* A Dify account — [cloud](https://cloud.dify.ai/signin) or self-hosted

## Method 1: CometAPI plugin (recommended)

The easiest way to connect. Dify Marketplace provides an official CometAPI plugin that handles the integration automatically.

<Steps>
  <Step title="Get your CometAPI API key">
    Log in to the [CometAPI dashboard](https://www.cometapi.com/console). Click **Add API Key** and copy your key.

    <Frame>
      <img src="https://mintcdn.com/cometapi/SZhlxZhCnMLn__BW/images/overview/810968_364191.png?fit=max&auto=format&n=SZhlxZhCnMLn__BW&q=85&s=aef81a83f29f8eb16655ed4060425f50" alt="CometAPI dashboard showing the Add API Key button and key list" width="3824" height="1892" data-path="images/overview/810968_364191.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/cometapi/HhtmQffktazbxUvS/images/overview/810968_364193.png?fit=max&auto=format&n=HhtmQffktazbxUvS&q=85&s=d893f659267150d0faf45f99eb5dffc1" alt="CometAPI API key details showing the base URL https://api.cometapi.com" width="2434" height="1232" data-path="images/overview/810968_364193.png" />
    </Frame>
  </Step>

  <Step title="Install the CometAPI plugin in Dify">
    In Dify, go to **Plugins** → **Install Plugin** → **Marketplace**. Search for `cometapi` and install it.

    <Frame>
      <img src="https://mintcdn.com/cometapi/E4FFvyMYmaOZoldp/images/integrations/810968_360267.png?fit=max&auto=format&n=E4FFvyMYmaOZoldp&q=85&s=85e4b1a60c912aa98c182ed731cde19f" alt="Dify plugin marketplace search results showing the CometAPI plugin" width="1875" height="916" data-path="images/integrations/810968_360267.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/cometapi/E4FFvyMYmaOZoldp/images/integrations/810968_360269.png?fit=max&auto=format&n=E4FFvyMYmaOZoldp&q=85&s=695d0f5fde8d4c8aad398048b3b504fd" alt="CometAPI plugin installation confirmation dialog in Dify" width="1865" height="896" data-path="images/integrations/810968_360269.png" />
    </Frame>
  </Step>

  <Step title="Add your API key">
    Go to **Settings** → **Model Provider** → **CometAPI** → **Open Settings**. Paste your CometAPI API key and click **Save**.
  </Step>

  <Step title="Add models">
    Enter a model ID from the [CometAPI Models page](/overview/models) and click **Add**.

    <Frame>
      <img src="https://mintcdn.com/cometapi/SZhlxZhCnMLn__BW/images/integrations/810968_362636.png?fit=max&auto=format&n=SZhlxZhCnMLn__BW&q=85&s=9aee58e6532ba58d69eb7673e6c45293" alt="Dify model provider settings showing the CometAPI configuration form" width="1256" height="880" data-path="images/integrations/810968_362636.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/cometapi/SZhlxZhCnMLn__BW/images/integrations/810968_362637.png?fit=max&auto=format&n=SZhlxZhCnMLn__BW&q=85&s=46c8b360d87cfad2adc1cd9f18dd7f25" alt="Dify model list with CometAPI models successfully added" width="1935" height="870" data-path="images/integrations/810968_362637.png" />
    </Frame>
  </Step>

  <Step title="Test the connection">
    Create a chatbot or workflow and select a CometAPI model. Send a test message — a successful response confirms the integration is working.

    <Frame>
      <img src="https://mintcdn.com/cometapi/SZhlxZhCnMLn__BW/images/integrations/810968_362638.png?fit=max&auto=format&n=SZhlxZhCnMLn__BW&q=85&s=c729bbc0f3bef82a89305434c08ec313" alt="Dify chat interface showing a successful response from a CometAPI model" width="1910" height="924" data-path="images/integrations/810968_362638.png" />
    </Frame>
  </Step>
</Steps>

## Method 2: OpenAI-compatible provider

Use this method to add models not covered by the CometAPI plugin, such as Claude, Grok, or Gemini — or to use custom model names.

<Steps>
  <Step title="Open model provider settings">
    Go to **Settings** → **Model Provider** → **OpenAI-API-compatible** → **Add Model**.
  </Step>

  <Step title="Configure the model">
    Fill in the following fields:

    | Field        | Value                                       |
    | ------------ | ------------------------------------------- |
    | Model type   | LLM                                         |
    | Model name   | Model ID from CometAPI (must match exactly) |
    | API key      | Your CometAPI API key                       |
    | API base URL | `https://api.cometapi.com/v1`               |

    Click **Save**.

    <Frame>
      <img src="https://mintcdn.com/cometapi/E4FFvyMYmaOZoldp/images/integrations/810968_354447.png?fit=max&auto=format&n=E4FFvyMYmaOZoldp&q=85&s=a6752a58cf43a3c7658da7b276ed5c1e" alt="Dify OpenAI-compatible provider form with CometAPI values filled in" width="1910" height="1009" data-path="images/integrations/810968_354447.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/cometapi/E4FFvyMYmaOZoldp/images/integrations/810968_354448.png?fit=max&auto=format&n=E4FFvyMYmaOZoldp&q=85&s=18caf18d11f4f0aa6741471016bcb14f" alt="Dify model list showing a newly saved CometAPI-compatible model entry" width="1953" height="965" data-path="images/integrations/810968_354448.png" />
    </Frame>
  </Step>
</Steps>

<Tip>
  For model identifiers, refer to the [CometAPI Models page](/overview/models). The model ID in Dify must exactly match the identifier used in CometAPI.
</Tip>

## Troubleshooting

If a call fails, check:

* The API key is correct and has available balance
* The model ID matches exactly what CometAPI expects
* The API base URL includes `/v1` (required for the OpenAI-compatible method)

For further help, visit the [CometAPI support page](https://www.cometapi.com/support/).
