> ## 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

<AccordionGroup>
  <Accordion title="The API key fails">
    Confirm that the API key is correct and has available balance.
  </Accordion>

  <Accordion title="The model ID fails">
    Confirm that the model ID matches exactly what CometAPI expects.
  </Accordion>

  <Accordion title="The API base URL fails">
    Confirm that the API base URL includes `/v1` for the OpenAI-compatible method.
  </Accordion>

  <Accordion title="Further help">
    Visit the [CometAPI support page](https://www.cometapi.com/support/).
  </Accordion>
</AccordionGroup>

<script type="application/ld+json">
  {`
    {
    "@context": "https://schema.org",
    "@graph": [
      {
        "@type": "HowTo",
        "@id": "https://apidoc.cometapi.com/integrations/dify#howto",
        "name": "Connect Dify to CometAPI",
        "description": "Use this guide to connect Dify to CometAPI by setting the base URL, API key, and model or provider options.",
        "step": [
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/dify#step-1",
            "position": 1,
            "name": "Get your CometAPI API key",
            "text": "Create or open your CometAPI account, then copy an active API key from the dashboard."
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/dify#step-2",
            "position": 2,
            "name": "Install the CometAPI plugin in Dify",
            "text": "Complete the Install the CometAPI plugin in Dify step in the Connect Dify to CometAPI guide."
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/dify#step-3",
            "position": 3,
            "name": "Add your API key",
            "text": "Complete the Add your API key step in the Connect Dify to CometAPI guide."
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/dify#step-4",
            "position": 4,
            "name": "Add models",
            "text": "Complete the Add models step in the Connect Dify to CometAPI guide."
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/dify#step-5",
            "position": 5,
            "name": "Test the connection",
            "text": "Select a current model ID from the CometAPI Models page, then send a test request from the integration."
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/dify#step-6",
            "position": 6,
            "name": "Open model provider settings",
            "text": "Complete the Open model provider settings step in the Connect Dify to CometAPI guide."
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/integrations/dify#step-7",
            "position": 7,
            "name": "Configure the model",
            "text": "Complete the Configure the model step in the Connect Dify to CometAPI guide."
          }
        ]
      },
      {
        "@type": "BreadcrumbList",
        "itemListElement": [
          {
            "@type": "ListItem",
            "position": 1,
            "name": "CometAPI Docs",
            "item": "https://apidoc.cometapi.com/"
          },
          {
            "@type": "ListItem",
            "position": 2,
            "name": "Integrations",
            "item": "https://apidoc.cometapi.com/integrations"
          },
          {
            "@type": "ListItem",
            "position": 3,
            "name": "Connect Dify to CometAPI",
            "item": "https://apidoc.cometapi.com/integrations/dify"
          }
        ]
      }
    ]
    }
    `}
</script>
