Chatting in the AnythingLLM desktop app is one way to reach a workspace; the developer API is the other. A script can ask the same workspace the same question and get the answer back as JSON — the shape a help-desk bot, a scheduled report, or any small automation needs. The workspace still answers from its own model and its embedded documents, so the API route needs a working chat model first, exactly as the app does.
Copy a developer API key
Open the settings with the wrench icon at the bottom of the workspace sidebar, where Developer API sits under Tools, and copy a key with Copy API Key. If the list is empty, Generate New API Key on the same page creates one; on a multi-user instance only an administrator can open this page. Store the key in a shell variable through a hidden read prompt, so it never lands in your shell history:
read -rs ANYTHINGLLM_API_KEY
The -s flag hides the pasted key and -r keeps it unchanged. The variable lasts only for this shell session.
Find the workspace slug and send a message
Requests name the workspace by its slug — the lowercase, hyphenated form of its name that AnythingLLM assigns when the workspace is created. List the workspaces to find it:
curl -sS -H @- http://localhost:3001/api/v1/workspaces \
<<< "Authorization: Bearer $ANYTHINGLLM_API_KEY" | python3 -m json.tool
Then send a chat message to that workspace’s chat endpoint, choosing a mode. chat lets the model answer from its own general knowledge as well as the workspace documents, while query answers only from embedded documents and declines when nothing relevant is found:
curl -sS -H @- -H 'Content-Type: application/json' \
-d '{"message": "What does a support desk do? Answer in one sentence.", "mode": "chat"}' \
http://localhost:3001/api/v1/workspace/support-desk/chat \
<<< "Authorization: Bearer $ANYTHINGLLM_API_KEY" | python3 -m json.tool
The endpoint holds the connection open until the model has finished. The answer is in textResponse, the document chunks it used are in sources, and "close": true with "error": null shows the reply finished without a failure. A second reference confirms the same endpoint from the project’s own Swagger definition, and adds a streaming variant at /stream-chat plus thread endpoints for separate conversations in one workspace.
| Check | What you should see | If you do not see it |
|---|---|---|
| Key accepted | The workspaces list comes back with your workspace and its slug | A 403 with {"error":"No valid api key found."} — the key is wrong or missing |
| Workspace | The slug matches a real workspace, such as support-desk |
Status 400 — the slug matches no workspace |
| Answer | textResponse holds a one-sentence answer |
In query mode with no matching document, it holds the refusal “There is no relevant information in this workspace to answer your query.” |
Expected result. We checked a step-by-step AnythingLLM API guide for the key page, the workspaces list, the chat endpoint, the modes, and the error replies, and a second reference for the same endpoint from the project’s Swagger definition. We did not run AnythingLLM.
Limits
The key is powerful: in AnythingLLM 1.19.0 it is not limited to one workspace or to chat, so the key behind a chat integration can also read, change, and delete every workspace on the instance — keep it in an environment variable and never in a repository. The base address above is for an instance on your own computer (http://localhost:3001); an instance on another host uses its own address. The workspace needs a chat model provider configured before the API can return anything useful, and the wording of the answer changes from run to run. We did not run AnythingLLM, so no reply here is a recorded result.
Sources
- AnythingLLM workspace chat API guide (third-party) — Developer API key page, read -rs key storage, GET /api/v1/workspaces, POST /api/v1/workspace/{slug}/chat, chat versus query mode, textResponse, 403 and 400 errors
- AnythingLLM skill reference (third-party) — developer REST API under /api/v1, Swagger at /api/docs, POST /v1/workspace/{slug}/chat and /stream-chat, answer in textResponse, chunks in sources
