-
Notifications
You must be signed in to change notification settings - Fork 540
docs: clarify API tool and MCP support #1166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
zuyua9
wants to merge
1
commit into
open-webui:main
Choose a base branch
from
zuyua9:docs/api-tool-use-clarity-zuyua9
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -258,6 +258,63 @@ The `outlet()` function only runs when the WebUI calls `/api/chat/completed` aft | |
| For more details on writing filters that work with API requests, see the [Filter Function documentation](/features/extensibility/plugin/functions/filter#-filter-behavior-with-api-requests). | ||
| ::: | ||
|
|
||
| ### 🛠️ Using Tools and External Connections in Direct API Calls | ||
|
|
||
| Yes. Direct API requests can use Open WebUI-managed tools, but the exact behavior depends on **which tool type** you want and **how the target model is configured**. | ||
|
|
||
| #### Direct API Tooling Rules | ||
|
|
||
| | Tool Type | Works in direct API calls? | What must be true | | ||
| |-----------|----------------------------|-------------------| | ||
| | **Built-in system tools** (knowledge, notes, memory, channels, web search, code interpreter, image generation) | ✅ Yes | The target model must use **Native Mode / function calling**, **Builtin Tools** must stay enabled for that model, and any required global feature flags must already be enabled. | | ||
| | **Workspace Tools / OpenAPI tools / MCP tools** | ✅ Yes | The request must target a model or request context that exposes those tools, and the authenticated user must have access to them. | | ||
| | **OAuth 2.1 MCP tools that still need browser consent** | ⚠️ Only after prior authorization | Pure API calls cannot complete an interactive browser redirect. If the MCP tool has not already been authorized, the request will fail until a user finishes the OAuth flow in the UI first. | | ||
|
|
||
| #### Native Mode Is Required for Tool Calling | ||
|
|
||
| For direct API requests, tool calling is a **Native Mode** feature. If the model is using legacy/default prompt-based function calling, Open WebUI will not inject the built-in tool surface described in the [Tools guide](/features/extensibility/plugin/tools#built-in-system-tools-nativeagentic-mode). | ||
|
|
||
| #### Built-in Tool Toggles for Direct API Clients | ||
|
|
||
| The WebUI normally controls **Web Search**, **Image Generation**, **Code Interpreter**, and similar capabilities with per-chat toggles. Direct API clients can express the same intent by sending a `features` object in the chat completion request body: | ||
|
|
||
| ```json | ||
| { | ||
| "model": "gpt-4o", | ||
| "messages": [ | ||
| { | ||
| "role": "user", | ||
| "content": "Search the web for the latest Open WebUI release notes." | ||
| } | ||
| ], | ||
| "features": { | ||
| "web_search": true, | ||
| "code_interpreter": false, | ||
| "image_generation": false, | ||
| "memory": false | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| These request-level flags do **not** override admin or model restrictions. They only enable features that are already allowed globally and for the selected model. | ||
|
|
||
| #### Selecting Workspace / External Tools | ||
|
|
||
| When you need specific Open WebUI-managed tools (including external OpenAPI or MCP connections), include the relevant tool selection in the request context, typically via `tool_ids`. Those selected tool IDs are then visible to filters and other internal processing as `__metadata__.tool_ids`. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'typically'? |
||
|
|
||
| Direct API requests still follow the same access-control rules as the WebUI: | ||
|
|
||
| - the user must be allowed to use the selected tool | ||
| - model-level capability settings still apply | ||
| - tool-specific limits and provider requirements still apply | ||
|
|
||
| #### Practical Guidance | ||
|
|
||
| - Use `POST /api/chat/completions` when you want Open WebUI to orchestrate tool calling, file context, filters, and attached knowledge. | ||
| - Use `POST /api/v1/messages` if you prefer Anthropic-compatible clients but still want Open WebUI's routing layer. | ||
| - Use attached `files` / `collections` when you want deterministic RAG context injection instead of autonomous tool use. | ||
| - Pre-authorize OAuth-based MCP tools in the UI before relying on them from unattended API clients. | ||
|
|
||
| ### 🦙 Ollama API Proxy Support | ||
|
|
||
| If you want to interact directly with Ollama models—including for embedding generation or raw prompt streaming—Open WebUI offers a transparent passthrough to the native Ollama API via a proxy route. | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning block "tool calling will not work if .."