Interactive API documentation helps while an integration is being built, but on a production server it hands every visitor a map of the endpoints worth probing. AnythingLLM publishes its developer API documentation as a Swagger page at /api/docs, readable without an API key, and its DISABLE_SWAGGER_DOCS setting removes that page from a self-hosted instance.

Removing the page hides the endpoint list, not the API. Requests that carry a valid API key keep working afterwards and requests without one are refused as before, so existing integrations need no changes. Who can call the API still depends on how its keys are handled and how widely the instance is reachable on the network.

AnythingLLM reads the setting from its environment file only when the server starts. On a Docker installation with a mounted .env file, the change therefore needs a container restart, which briefly takes the instance offline for everyone using it. Once the setting is active, the documentation address opens AnythingLLM's own page-not-found screen instead of the endpoint reference.

Steps to disable API docs in AnythingLLM:

  1. Check that http://localhost:3001/api/docs opens the AnythingLLM Developer API documentation in your browser.

    The Swagger page lists every developer API endpoint with its parameters and responses, and it loads without a sign-in or an API key. An instance on another host uses its own address in place of localhost:3001.

  2. Open the AnythingLLM environment file from the Docker storage directory in a text editor with sudo.
    $ sudo nano "$HOME/anythingllm/.env"

    This is the .env file created during the Docker installation and mounted in the container at /app/server/.env. Its directory belongs to UID 1000 with mode 700, so an account with another UID can open the file only through sudo, and the same command works for the owning account. sudoedit refuses files under a directory its user can write, which on Ubuntu 26.04 includes any path in the home directory. nano is Ubuntu's default text editor. The file also holds provider credentials and the keys that encrypt AnythingLLM's saved data, so its existing lines must stay unchanged. A different storage location needs its own .env path.

  3. Disable the Swagger documentation by adding DISABLE_SWAGGER_DOCS=“true” as a new line at the end of the environment file.
    DISABLE_SWAGGER_DOCS="true"

    AnythingLLM 1.19.0 removes the documentation only for the exact lowercase value true. Values such as 1 or TRUE leave the Swagger page published. If the file already defines DISABLE_SWAGGER_DOCS, edit that line instead of adding a second one.

  4. Exit the editor with the file saved.

    nano writes the change into the existing .env file, so the file keeps the owner and permissions the Docker installation gave it and the container can still read it. The running server keeps its old settings until the container restarts.

  5. Restart the AnythingLLM container to load the new setting.

    AnythingLLM is unavailable until the restarted server is ready again, which can take half a minute or more. Chats in progress and documents being processed are interrupted for every user of the instance.

    $ docker restart --timeout 30 anythingllm
    anythingllm

    anythingllm is the container name from the Docker installation. The restart keeps the same container, storage and .env mount. A value passed with -e when the container was created is not reread by a restart; changing it requires recreating the container.

  6. Confirm in the container log that AnythingLLM started with the Swagger documentation disabled.
    $ docker logs anythingllm 2>&1 | grep 'SWAGGER DISABLED'
    [backend] info: [SWAGGER DISABLED] Swagger documentation is disabled via DISABLE_SWAGGER_DOCS environment variable.

    The server writes this line at startup only when it reads DISABLE_SWAGGER_DOCS="true". No output means the server is still starting or did not read the value; a misspelled name or another value keeps the documentation enabled.
    Related: How to view Docker logs for AnythingLLM

  7. Verify that http://localhost:3001/api/docs now shows AnythingLLM's 404 - Page Not Found screen instead of the API documentation.

    The web interface answers the address with this screen and an HTTP 200 status, so a scanner that expects a 404 status code will not see one; the missing Swagger page is the result to look for. Developer API requests with a valid key keep returning their normal responses.

Share this guide