Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

docs: Update API documentation with correct authentication flow

LearningCircuit6fd76ba14a48
diff --git a/README.md b/README.md
index 1aa27f2367..bfd9ccaf67 100644
--- a/README.md
+++ b/README.md
@@ -249,13 +249,20 @@ import requests
# Create session and authenticate
session = requests.Session()
+
+# First, get the login page to retrieve CSRF token for login
+login_page = session.get("http://localhost:5000/auth/login")
+# Extract CSRF token from HTML form (use BeautifulSoup or regex)
+# For simplicity, assuming you have the token
+
+# Login with form data (not JSON) including CSRF token
session.post("http://localhost:5000/auth/login",
- json={"username": "user", "password": "pass"})
+ data={"username": "user", "password": "pass", "csrf_token": "..."})
-# Get CSRF token
+# Get CSRF token for API requests
csrf = session.get("http://localhost:5000/auth/csrf-token").json()["csrf_token"]
-# Make API request
+# Make API request with CSRF header
response = session.post(
"http://localhost:5000/research/api/start",
json={"query": "Explain CRISPR gene editing"},
diff --git a/docs/api-quickstart.md b/docs/api-quickstart.md
index 580d57e0da..dcdc3686eb 100644
--- a/docs/api-quickstart.md
+++ b/docs/api-quickstart.md
@@ -31,27 +31,38 @@ Example authentication flow:
```python
import requests
+from bs4 import BeautifulSoup
# Create a session to persist cookies
session = requests.Session()
-# 1. Login
+# 1. Get login page and extract CSRF token for login
+login_page = session.get("http://localhost:5000/auth/login")
+soup = BeautifulSoup(login_page.text, 'html.parser')
+csrf_input = soup.find('input', {'name': 'csrf_token'})
+login_csrf = csrf_input.get('value') if csrf_input else None
+
+# 2. Login with form data (not JSON) including CSRF
login_response = session.post(
"http://localhost:5000/auth/login",
- json={"username": "your_username", "password": "your_password"}
+ data={
+ "username": "your_username",
+ "password": "your_password",
+ "csrf_token": login_csrf
+ }
)
-if login_response.status_code == 200:
+if login_response.status_code in [200, 302]:
print("Login successful")
# Session cookie is automatically stored
else:
print(f"Login failed: {login_response.text}")
-# 2. Get CSRF token for API requests
+# 3. Get CSRF token for API requests
csrf_response = session.get("http://localhost:5000/auth/csrf-token")
csrf_token = csrf_response.json()["csrf_token"]
-# 3. Make API requests with authentication
+# 4. Make API requests with CSRF header
headers = {"X-CSRF-Token": csrf_token}
api_response = session.post(
"http://localhost:5000/research/api/start",