Building Python tools for Open WebUI

Python tools let Open WebUI models call internal logic on your own server, configured through valves and governed by review and permission rules. This page covers when to build one, how to set it up, and what to confirm before users depend on it.

On this page

When teams build Python tools for Open WebUI

A Python tool is code that runs inside the Open WebUI server, and models can call it when a conversation needs data or an action that the model cannot provide on its own. Teams usually reach for this approach when a shared Open WebUI deployment needs to look up or act on internal data, such as a ticket status, a product catalog entry or an internal reference record, and the team controls both the code and the systems it touches. Because the code runs in the server process, it can use the server's network position and credentials, which is the main reason it is fast to build and also the main reason it needs review.

The Open WebUI features documentation describes tools as functions that models can invoke during a chat, configured through the admin or workspace interface and made available to selected models and users. Before choosing this route, a team should compare it with the alternatives covered in sibling pages: OpenAPI tool servers, which keep integration logic outside the Open WebUI process, and server-side tool calling through the API, which runs tools for scripted callers. Python tools fit best when the logic is small, owned by the platform team and reviewed like any other server code. They fit poorly when the logic belongs to another team's release cycle or needs a separate security boundary.

This page covers how a tool is structured, how valves expose configuration such as endpoints and limits to administrators, the permission and review rules that apply because tools execute on the server, and the checks to run before a tool reaches users. Tool behavior, decorator names, valve definitions and API fields change between releases, so confirm each detail against the documentation for the exact Open WebUI version in use, including the release you plan to upgrade to, before writing production code. Treat the examples here as a starting point to verify, not as a reference.

How a model's tool call reaches your server

The path starts with a user prompt in Open WebUI, which is sent to the model provider along with the tool definitions the workspace has enabled. The provider returns a tool call decision, and the Open WebUI server, not the provider, runs the Python tool function. That function reads or writes internal systems using credentials held on the server, and the result goes back to the model as text. Check the two trust boundaries: the provider sits outside your network, and the tool code sits inside it with access to your systems. Valves are read by the server when the tool runs, so that is where configuration and secrets need controls.

Tool calls run on the Open WebUI server, which crosses into your internal systems.

Configuration options and when each fits

This table compares four places a Python tool's settings can live: administrator valves, user-level settings, server configuration for secrets, and logic hard-coded in the tool. Read each row for what it suits, who can change it and the main risk, then confirm the exact keys in the Open WebUI features documentation for your release.

OptionBest suited toWho can change itMain risk
Valves set by administratorsShared settings such as endpoint URLs, timeouts, result limits and feature switches that every user should getWorkspace administrators in the Open WebUI interfaceA bad value affects every user at once, so changes need a test instance and a record of who changed them
User-level settings, where the docs allow themPreferences that differ per person, such as a default output format or a personal display choiceEach signed-in user, for their own copy of the settingUsers may set values the tool does not expect, so the tool must validate input and fail safely
Environment variables or server configurationSecrets such as API keys and service passwords, plus deployment-specific addressesWhoever controls the server, container or Kubernetes configurationSecrets may leak through logs, shell history or a shared compose file, and a value set here may not appear in the admin interface
Hard-coded logic in the toolFixed behavior the code owns, such as parsing rules or required headers that should never varyOnly people who can edit and redeploy the tool codeEvery change needs a code review and a redeploy, and secrets written into the file end up in version control
Confirm before relying on any optionExact valve keys, user-setting support and environment variable names for your releaseYour platform owner, checked against the features documentationParameter names change between releases, so an upgrade can silently ignore a setting that was renamed

Choosing between Python tools, OpenAPI tool servers and MCP

Use a Python tool when the capability is a small piece of logic the platform team owns, such as formatting a internal ticket reference, calculating a date window or looking up a value in a table the platform already reads. The code lives inside Open WebUI's workspace, so the platform team deploys, edits and reviews it with the rest of the platform.

  • Code location: the function runs in the Open WebUI process, so its source is stored with the platform configuration and reviewed alongside other platform changes.
  • Update ownership: the platform team edits the tool directly, which avoids a second service to deploy and version.
  • Review effort: short, readable functions are quick to review, but every tool runs with server access, so the review still applies.
  • Blast radius: a defect can affect the Open WebUI process itself, so test changes on a separate instance before they reach users.
  • Why a team might choose another pattern: if several applications need the same logic, or another team must own it, a separate service is easier to govern.

Before you commit to this pattern, confirm who can create and edit tools in your admin settings and where the source is kept under version control.

What a tool should expose to a model

A tool's function signature is part of the model's instructions, so design it as a narrow contract. Accept the fewest parameters the task needs, use typed and bounded inputs where possible, and avoid free-form arguments such as a raw query string or a path that can point anywhere on the server. Write the docstring for the model, not for the next developer: it should say what the function does, when it should be called, and when it should not. Models choose tools from these descriptions, so a vague docstring leads to wrong calls even when the code is correct. Keep one tool to one job. A function that both looks up and updates records is harder for a model to call safely and harder for a reviewer to assess.

Split read operations from write operations into separate functions. A read-only lookup can run without friction, while a write, delete or send action should be a distinct function that the reviewer can gate. Every write path needs a confirmation step, an audit record, or both. The confirmation can be a human approval inside the chat flow or a staged change that a person commits, depending on the risk. The audit record should capture the signed-in user, the arguments, the result and the time, and it should be written by the tool itself rather than relying on the model to report what it did. Confirm with your team how your Open WebUI release passes the requesting user's identity into tool code (the features and tools documentation for that release is the reference), because the permission model depends on it.

Permissions should follow the signed-in user, not a shared service account. If a tool reads records through one privileged credential, any user who can invoke the tool can see whatever that credential sees, and the group and resource permissions you configured in Open WebUI no longer limit the data. Where the target system supports it, pass the user's own token or map the user to a downstream role, and test with two accounts of different access levels to confirm that the tool refuses what the user should not see. Return errors to the model as short, specific messages such as the missing parameter, the denied permission, or the record not found, without stack traces, internal hostnames or credential details. Clear errors let the model correct its call, and sanitized errors keep internal configuration out of the chat transcript.

Build and enable a Python tool, step by step

This sequence takes a Python tool from a defined purpose to a workspace tool that only approved groups can call, with checks at each stage. Each step ends with evidence that the tool behaves as reviewed before it reaches production users.

  1. Define the tool's purpose and data sources

    The tool owner writes down the single job the tool will do, the systems it will read or write, the credentials it needs, and the users who should be able to trigger it. List each external endpoint the code will call, because every one of them is an outbound request made from the Open WebUI server. The step is done when the owner and the security reviewer agree on a one-page scope note that names the data sources and the intended groups. If the scope needs a second system, write it into the note now rather than adding it during coding.

  2. Write the tool code and its valves

    The engineer writes the Python class with the methods the model will call, docstrings that describe each method clearly enough for the model to choose correctly, and valves for settings that administrators should change without editing code, such as base URLs or result limits. Secrets go in valves or environment configuration handled by your secrets process, never hard-coded in the file. The step is done when the file loads in a development environment and each method returns a predictable structure for a known input. Keep outbound calls to the endpoints listed in the scope note only.

  3. Test in a non-production Open WebUI instance

    Install the tool on a separate Open WebUI instance that holds no production users, data or credentials. The features documentation describes the supported install methods (Docker and Docker Compose, Kubernetes with Helm, and pip install open-webui followed by open-webui serve), so choose the one that matches your production pattern to catch packaging differences early. Run the tool with test accounts and inputs that include malformed data, empty results and an unreachable endpoint. The step is done when every method returns a clear error message on failure and no test run changes data outside the test systems.

  4. Review the code with a second engineer

    A second engineer who did not write the tool reads every line, checks the outbound calls against the scope note, looks for places where user input is passed into shell commands, file paths, queries or URLs, and confirms that valves do not expose secrets to non-admin users. The reviewer records findings in the change ticket and the author fixes or justifies each one. The step is done when the reviewer signs the ticket and every finding is closed or accepted by the tool owner. Because tools run on the server with server access, treat this review as a gate, not a formality.

  5. Install the tool as a workspace tool

    An administrator adds the reviewed code to the production instance as a workspace tool, using the exact file version that passed review. Record the file hash or version identifier in the change record so the installed code can be matched to the reviewed code later. Set valves to production values through the administrator interface and confirm that the tool does not yet appear for general users. The step is done when the installed version matches the reviewed version and the valves show the production settings without exposing any secret values.

  6. Grant access to the approved groups

    Using role-based access control with groups and per-resource permissions, the administrator grants the tool to the approved groups only. Confirm the group membership in your identity provider matches what Open WebUI receives, especially if single sign-on or SCIM provisioning updates groups automatically. The step is done when a test user in an approved group sees the tool in the model's available tools and a test user outside every approved group does not see it.

  7. Verify with a test prompt and log check

    Run a test prompt as an approved user that should trigger the tool, then as a denied user with a prompt that asks for the same action. The denied user's attempt must not run the tool. Review the server logs and the tool's own output for the approved run, confirming the expected outbound call happened once, the returned data matches the test input, and no secrets appear in log lines. Record both results and the log locations in the change record. The step is done when the approved run succeeds, the denied run fails to trigger the tool, and the logs show no credential values.

Security rules that apply because tools run on the server

A Python tool runs inside the Open WebUI server process, so it inherits the server's credentials, network reach and data access. The cards below cover the risks that follow from that placement and the controls to set before a tool reaches users.

Server access and network position

A tool runs with the same operating system permissions and network position as the Open WebUI process. It can often reach internal databases, admin APIs and metadata endpoints that a user's browser never could. Before publishing a tool, confirm which hosts and ports the server can reach, and run Open WebUI with the least privilege its containers and service accounts need. Treat every tool as code with the server's reach.

Secrets in valves and environment settings

Valves hold configuration that tools read at runtime, and API keys often end up there. Anyone who can read valve values or the container environment can read those secrets, so the risk depends on who holds administrator access. Use credentials scoped to one purpose and one system, rotate them on a schedule your team can name, and confirm in the Open WebUI admin settings which roles can view tool configuration.

Tools that write data

A tool that creates tickets, edits records or sends messages changes systems of record, and a model can call it more often than a person expected. Limit write actions to a dedicated service account with only the required permissions, and prefer a read-only tool for first releases. Log each write with the caller, arguments and result so that a bad change can be traced and reversed.

Unreviewed code from outside

Community tools and copied snippets run with full server access and have usually not been audited by your team. Before installation, read the full source, check every import and network call, and run the tool on a test instance with dummy data. Record who approved each tool and which version was installed, so the approved code can be matched to what runs in production.

Outbound requests from the tool

A tool that fetches URLs or calls external APIs can send internal data out, or reach internal addresses on the model's behalf. Restrict outbound traffic at the network layer to a list of approved destinations, and review any code that builds URLs from user or model input. Confirm the egress rules with your network team, because application code alone does not enforce them.

Harmful arguments from prompt injection

Text in a web page, document or chat can steer a model into calling a tool with arguments the user never intended. The tool still runs with its own permissions, so validate every argument on the server side, reject values outside expected ranges, and require confirmation for destructive actions. Keep audit logs of tool calls so that unexpected calls can be detected and investigated.

Running tools across replicas, upgrades and sign-out

Before a Python tool goes live on a multi-replica Open WebUI deployment, confirm where tool definitions and valve values are stored and whether every replica reads the same copy. The scaling guide says Redis holds shared state for sessions, websocket connections and application state, and that shared file storage keeps uploads and knowledge reachable from every replica. Tool records and their saved valve settings live in the application database and state layer, so ask your platform team to trace a valve change made in the admin interface to every replica that serves a chat. If one replica keeps a stale copy, a tool can run with an old endpoint or credential while others use the new one. Check this on a staging cluster by changing a valve on one replica and calling the tool from sessions that land on the others. Also confirm that any file a tool reads or writes is on shared storage, because a path that exists on one container alone will fail intermittently under load balancing.

Tool code can break between Open WebUI releases, and the interface around tools changes as well. Open WebUI v0.12.3 was published on October 16, 2026, following v0.12.0 on October 10 and v0.11.0 in July, so a tool written against one minor release may not behave the same on the next. Treat every upgrade as a change to the tool as well as to the platform. Keep a staging instance on the same version and database type as production, import a copy of your tool set, and run a fixed script of test prompts that exercise each tool, including the failure paths. Compare tool calls, returned values and error messages with the last known good run. Read the release notes for changes to tool function signatures, valve handling and the Python dependencies available to tools before you schedule the production upgrade, and record which version each tool was last verified against.

Without Redis, signing out of Open WebUI does not revoke tokens. They stay valid until they expire, by default after 4 weeks. For most chat use this is a manageable window, but it matters when a tool holds user-scoped access, such as a tool that calls a ticketing or document API with the signed-in user's delegated token. A departed employee's session can keep calling that API for up to the full token lifetime. Confirm whether your topology includes Redis, and if it does not, shorten the token lifetime, rely on your identity provider to end sessions, and remove the user's access at the source system the tool calls. Ask the tool's owners which credential each tool uses: a service account set in a valve is revoked independently of Open WebUI sign-out, while a passed-through user token is not. Write this decision into the tool's review record so that the next person who changes the credential model sees the sign-out consequence.

Limits to confirm in your environment

Python tools run inside the Open WebUI server process, so their behavior depends on the release, the deployment topology and the license you hold. The items below are the points to verify on a test instance before a tool design is locked, and each one names who can confirm it.

Exact tool interface and valve syntax

The class structure, function signatures, docstring conventions and valve declarations for workspace tools can change between releases. Confirm the interface against the documentation for the version you run, then build a minimal tool and check that the model sees the function name and description you expect. Ask the vendor documentation and your own test instance, not an older blog post or community sample.

Latest release cited
v0.12.3
Open WebUI features docs

Tool code across replicas

Tools are stored in the application database and loaded by each process, so a tool edit may not reach every replica at the same moment. Check how your deployment syncs tool code and valve values, and test a change against two replicas. Your platform team should confirm this against the scaling guidance for your topology, because a stale tool on one replica produces inconsistent answers.

Scaling Open WebUI docs

Identity the tool receives per request

A tool may need the signed-in user's identity to filter data or enforce permissions, but the fields passed to the tool depend on the release. Confirm which user attributes, roles and group memberships arrive with each call, and whether a tool can rely on them for authorization. Test with a standard user and an admin account, and do not treat a valve value set by an admin as proof of the caller's identity.

Timeouts and error handling

Confirm how a raised exception, a timeout or an empty return value reaches the model and the end user. Some releases pass error text back to the model, which can lead it to retry, invent an answer or expose internal details in the response. Your test instance should include a failing upstream call and a slow call, and your team should decide which error messages are safe to show.

Python packages on the server

A tool that imports a library needs that library installed in the same Python environment that runs Open WebUI, and a container rebuild may remove packages installed by hand. Confirm with your platform team whether your image can install dependencies, whether they are pinned, and whether an air-gapped network can reach the package index. Every package is also code running with server access, so include it in the review.

Enterprise License versus free software

Check what the Open WebUI License requires for your user count and branding, and whether features your tool design depends on are included in the free software or the Enterprise License. Ask Open WebUI enterprise sales for the feature list and pricing, since pricing is not published. Your procurement and legal teams should confirm the terms in writing before the tool roadmap assumes a feature.

Branding clause threshold
50 users
Open WebUI License docs

Questions teams ask before building Python tools

How much effort does a first Open WebUI Python tool take?

A first tool that reads one internal system and returns text can be small, but the effort grows with each system it touches, each write path it adds and each review and test step the organization requires. The main drivers are the number of systems, whether the tool changes data or only reads it, how the tool authenticates to each system, and how much testing and sign-off the change process demands. Ask for the effort to be broken down by system, write path and review step so the quote shows where the time goes. Pricing is not published, so the figure comes from a written scope rather than a standard rate.

Can our own developers build a Python tool without a partner?

Yes, for a read-only tool built by an in-house Python developer who understands the target system and can test it on a non-production instance. The work gets harder when the tool must enforce per-user access control, write data, handle credentials safely or pass a formal security review. Because tools run on the Open WebUI server with that server's access, a mistake affects the whole deployment, not one user. Decide early whether your team has the time to own testing, permission design and ongoing maintenance after the first release.

What does a Python tool project need from our team?

Plan for four inputs before work starts: a test Open WebUI instance that mirrors production settings, service accounts with the least access the tool needs in each target system, named reviewers who will read the code and approve it, and a change window for the production release. Your team should also confirm which Open WebUI version runs in production, since tools depend on the platform's behavior. Ask the implementation partner to list these inputs in the written scope so that delays from missing accounts or approvals are visible from the start.

How long does it take to move a tool from test to production?

The timing depends mostly on the review and identity work, not on the Python code itself. Code review, security testing, the creation of service accounts and the approval of the change window each follow your own change process, so the duration can only be confirmed with your change and security teams. Ask which approvals are required, who signs them and how long each usually takes in your organization. Build the schedule around those gates and keep a test instance available for retesting after each fix.

What does a DeployOpen engagement cover for Python tools?

DeployOpen plans, implements and tests Open WebUI deployments inside your own infrastructure, and most engagements are fixed-scope with deliverables and timelines agreed in writing before work starts. For Python tools, that typically means defining the tool's purpose and permissions, building it against a test instance, testing it for access control and data exposure, and documenting how it is reviewed and maintained. Ongoing support, upgrades and continuous testing are available as retainers. DeployOpen prepares evidence for compliance assessments but does not issue audit reports or certifications.

How are Python tool projects quoted?

Quotes follow from a written, fixed scope, so the scope must be agreed before a price is discussed. DeployOpen does not publish a price list. A useful quote separates the one-time build, testing and review work from any recurring support or retesting, and it states which systems, write paths, reviewers and environments are included. Ask the provider to show what changes the price if the scope grows, such as adding a system or a second review cycle, and what your team must supply to keep the timeline.

Which parts of a tool project carry the most risk?

The highest risk sits in permissions and review. A tool that runs server-side can reach any system its service account can reach, so an overly broad account or a tool that writes data without checks can cause damage that is hard to reverse. Unreviewed code also creates exposure if it handles secrets poorly or logs sensitive content. Define the access each tool needs before coding, restrict its credentials, require a human review of every change and test with realistic but non-production data before release.

How DeployOpen scopes and delivers Python tool work

DeployOpen plans, builds, tests, documents and supports Python tools for Open WebUI inside your own infrastructure, so the tools run where your identity, data and approval processes already live. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.

How we scope

  • We list the tools, the systems each tool calls and the users or groups allowed to run them.
  • The written scope names which valves are operator-set and which values users may never see.
  • We agree how each tool is reviewed, tested and approved before it reaches production users.

How we build

  • We write tools with typed parameters, clear docstrings and valves for endpoints and limits.
  • Credentials stay in server-side configuration, never in model-visible prompts or tool output.
  • Each tool is tested on a non-production Open WebUI instance with a dedicated test account.

How we hand over

  • You receive the tool source, a review checklist, valve documentation and a permission map.
  • We document the install, update and rollback steps your team will run on its own instance.
  • Test cases and sample prompts are delivered so your reviewers can repeat the checks.

How we support

  • Ongoing support, upgrades and retesting after each Open WebUI release are available as a retainer.
  • We can retest tools when a backing API, schema or Open WebUI version changes.
  • Support scope, response expectations and fees are set in the written agreement, not in this page.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.