API Extentions not well explained #912

Closed
opened 2026-02-21 17:28:59 -05:00 by yindo · 6 comments
Owner

Originally created by @ghost on GitHub (Jan 15, 2024).

Self Checks

Provide a description of the help you need

I have gone into settings and api extentions and tried to add one. Every api I have tried fails with a 404.. what exactly is it exspecting? what is an example of a compatable api?

Originally created by @ghost on GitHub (Jan 15, 2024). ### Self Checks - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to file this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). ### Provide a description of the help you need I have gone into settings and api extentions and tried to add one. Every api I have tried fails with a 404.. what exactly is it exspecting? what is an example of a compatable api?
yindo added the 📚 documentation label 2026-02-21 17:28:59 -05:00
yindo closed this issue 2026-02-21 17:28:59 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 15, 2024):

🤖

Hey @vontainment! 👋 I'm Dosu, an AI assistant here to lend a hand while we wait for a real human to dive in. I'm suited up to help squash bugs, answer your queries, and even guide you on your path to becoming a contributor. So, consider me your friendly helper bot in the coding realm. Let's get to solving! 🚀

To add API extensions in the dify settings, you need to create an instance of the APIBasedExtension class and add it to the database. The APIBasedExtension class represents a table in the database where each row corresponds to an API extension.

Here is an example of how you can add an API extension:

from api.models.api_based_extension import APIBasedExtension, APIBasedExtensionPoint
from extensions.ext_database import db
import uuid

# Create a new API extension
new_api_extension = APIBasedExtension(
    tenant_id=uuid.uuid4(),  # Replace with your tenant_id
    name='My API Extension',
    api_endpoint='https://myapi.com/endpoint',  # Replace with your API endpoint
    api_key='myapikey',  # Replace with your API key
)

# Add the new API extension to the session
db.session.add(new_api_extension)

# Commit the session to save the changes
db.session.commit()

In this example, replace 'https://myapi.com/endpoint' with the URL of your API endpoint and 'myapikey' with your API key. The tenant_id should be the UUID of your tenant.

If you're getting a 404 error, it might be because the api_endpoint you're providing does not exist or is not reachable. Make sure that the API endpoint you're using is correct and try again. You can find more details in the api/models/api_based_extension.py file.

If you're trying to add an API extension from the user interface, you would need to make a POST request to the '/api-based-extension' endpoint. This is handled by the post method in the APIBasedExtensionAPI class. The process requires the user to be logged in, the account to be initialized, and the setup to be completed. You can find more details in the api/controllers/console/extension.py file.

I hope this helps! If you have any other questions, feel free to ask.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot[bot] commented on GitHub (Jan 15, 2024): _🤖_ <!-- Greeting --> Hey @vontainment! 👋 I'm [Dosu](https://dosu.dev), an AI assistant here to lend a hand while we wait for a real human to dive in. I'm suited up to help squash bugs, answer your queries, and even guide you on your path to becoming a contributor. So, consider me your friendly helper bot in the coding realm. Let's get to solving! 🚀 <!-- Answer --> To add API extensions in the dify settings, you need to create an instance of the `APIBasedExtension` class and add it to the database. The `APIBasedExtension` class represents a table in the database where each row corresponds to an API extension. Here is an example of how you can add an API extension: ```py from api.models.api_based_extension import APIBasedExtension, APIBasedExtensionPoint from extensions.ext_database import db import uuid # Create a new API extension new_api_extension = APIBasedExtension( tenant_id=uuid.uuid4(), # Replace with your tenant_id name='My API Extension', api_endpoint='https://myapi.com/endpoint', # Replace with your API endpoint api_key='myapikey', # Replace with your API key ) # Add the new API extension to the session db.session.add(new_api_extension) # Commit the session to save the changes db.session.commit() ``` In this example, replace `'https://myapi.com/endpoint'` with the URL of your API endpoint and `'myapikey'` with your API key. The `tenant_id` should be the UUID of your tenant. If you're getting a 404 error, it might be because the `api_endpoint` you're providing does not exist or is not reachable. Make sure that the API endpoint you're using is correct and try again. You can find more details in the [api/models/api_based_extension.py](https://github.com/langgenius/dify/blob/main/api/models/api_based_extension.py) file. If you're trying to add an API extension from the user interface, you would need to make a POST request to the '/api-based-extension' endpoint. This is handled by the `post` method in the `APIBasedExtensionAPI` class. The process requires the user to be logged in, the account to be initialized, and the setup to be completed. You can find more details in the [api/controllers/console/extension.py](https://github.com/langgenius/dify/blob/main/api/controllers/console/extension.py) file. I hope this helps! If you have any other questions, feel free to ask. ## Sources - [api/models/api_based_extension.py](https://github.com/langgenius/dify/blob/main/api/models/api_based_extension.py) - [api/controllers/console/extension.py](https://github.com/langgenius/dify/blob/main/api/controllers/console/extension.py) --- This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot.
Author
Owner

@ghost commented on GitHub (Jan 15, 2024):

Now I'm even more confused... I'm not even sure the API extensions are what I thought they are...

@ghost commented on GitHub (Jan 15, 2024): Now I'm even more confused... I'm not even sure the API extensions are what I thought they are...
Author
Owner

@crazywoola commented on GitHub (Jan 15, 2024):

The API extension on dify is a simple solution to call third-party services, which requires you pre-define the parameters in the extension, and config it in our application. It's not the same with the function calls like openai, it allows llm to decide when to call other services. We will support this way in our next version.

Also https://docs.dify.ai/advanced/extension/api_based_extension/cloudflare_workers check this out, this is much simpler than previous one.

@crazywoola commented on GitHub (Jan 15, 2024): The API extension on dify is a simple solution to call third-party services, which requires you pre-define the parameters in the extension, and config it in our application. It's not the same with the function calls like openai, it allows llm to decide when to call other services. We will support this way in our next version. Also https://docs.dify.ai/advanced/extension/api_based_extension/cloudflare_workers check this out, this is much simpler than previous one.
Author
Owner

@ghost commented on GitHub (Jan 15, 2024):

Okay thank you That helps a lot that actually that git repository example but understanding now thank you

@ghost commented on GitHub (Jan 15, 2024): Okay thank you That helps a lot that actually that git repository example but understanding now thank you
Author
Owner

@ghost commented on GitHub (Jan 16, 2024):

So I figured most of this out. but What I'm confiused with is, what is
"app_id": ""
and
"tool_variable":"
__"
used for? i noticed all variables in the app are added to input.

also if i turn on a tool... then it only seems to query it... is there a way to decisde when to query it and when not to?

@ghost commented on GitHub (Jan 16, 2024): So I figured most of this out. but What I'm confiused with is, what is "app_id": "______" and "tool_variable":"________" used for? i noticed all variables in the app are added to input. also if i turn on a tool... then it only seems to query it... is there a way to decisde when to query it and when not to?
Author
Owner

@crazywoola commented on GitHub (Jan 24, 2024):

So I figured most of this out. but What I'm confiused with is, what is "app_id": "" and "tool_variable":"__" used for? i noticed all variables in the app are added to input.

also if i turn on a tool... then it only seems to query it... is there a way to decisde when to query it and when not to?

Try to use our latest version, it supports letting the llm itself to decide when and what to use tools.

@crazywoola commented on GitHub (Jan 24, 2024): > So I figured most of this out. but What I'm confiused with is, what is "app_id": "**" and "tool_variable":"**__" used for? i noticed all variables in the app are added to input. > > also if i turn on a tool... then it only seems to query it... is there a way to decisde when to query it and when not to? Try to use our latest version, it supports letting the llm itself to decide when and what to use tools.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#912