Getting Started¶
This guide walks you through setting up and running the Clearview API locally, then making your first request.
Prerequisites¶
- Python 3.9+
pip- API keys for the following services:
| Service | Used for |
|---|---|
| OpenAI | Summarization (OPENAI_API_KEY) |
| ElevenLabs | Text-to-speech (ELEVENLABS_API_KEY) |
Installation¶
1. Clone the repository
2. Create and activate a virtual environment
python -m venv .venv
source .venv/Scripts/activate # Windows (bash)
# source .venv/bin/activate # macOS / Linux
3. Install dependencies
4. Configure environment variables
Create a .env file in the project root:
Running the API¶
The API starts at http://127.0.0.1:8000.
Verify it's running:
Expected response:
Interactive docs¶
FastAPI exposes auto-generated interactive docs while the server is running:
- Swagger UI —
http://127.0.0.1:8000/docs - ReDoc —
http://127.0.0.1:8000/redoc
Your first request¶
The following example analyzes a news article URL and retrieves the PDF report.
Step 1 — Analyze a document¶
import httpx
r = httpx.post(
"http://127.0.0.1:8000/clearview",
json={"input": "https://www.bbc.com/news/articles/example"},
timeout=120, # analysis takes time — several ML models run in parallel
)
data = r.json()
print("Word count:", data["word_count"])
print("Scam notes:", data.get("scam_notes"))
print("Bias notes:", data.get("bias_notes"))
const res = await fetch("http://127.0.0.1:8000/clearview", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ input: "https://www.bbc.com/news/articles/example" }),
});
const data = await res.json();
console.log("Word count:", data.word_count);
console.log("Scam notes:", data.scam_notes);
console.log("Bias notes:", data.bias_notes);
The response includes a pdf field containing the full report as a base64-encoded string.
Step 2 — Save the PDF¶
// In a browser
const bytes = atob(data.pdf);
const arr = new Uint8Array(bytes.length).map((_, i) => bytes.charCodeAt(i));
const blob = new Blob([arr], { type: "application/pdf" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "report.pdf";
a.click();
Next steps¶
- Clearview endpoint reference — full request/response details
- Audio endpoint reference — convert documents to speech
- Models reference — complete schema definitions