Quick start¶
The examples read your key and the API's address from two variables, as set in Authentication.
1. Submit a document¶
curl -X POST $ONTOCAST_API/process \
-H "Authorization: Bearer $ONTOCAST_KEY" \
-F "file=@paper.pdf" \
-F "facts_user_instruction=Extract material properties only"
The response lists one job per file, {"jobs": [{"job_id": …, "status": "IN_QUEUE", …}]}. Any multipart field name works for a file; repeat it to send several. For short text, send JSON to /process_unit, which treats the whole input as one unit:
curl -X POST $ONTOCAST_API/process_unit \
-H "Authorization: Bearer $ONTOCAST_KEY" -H "Content-Type: application/json" \
-d '{"text": "Perovskite cells reach 25% efficiency.", "render_mode": "facts"}'
To load a graph you already have, see Importing a fact graph.
2. Follow the job¶
status moves IN_QUEUE → STARTING → PROCESSING → COMPLETE, or ends in ERROR (see error) or ABORTED. While it runs, stage names the last finished pipeline step and units_total the number of content units. A queued job carries wait: its position among your queued jobs and a reason, plan_slot (your plan's running-job limit is reached), ontology_writer (jobs that write a project's ontologies run one at a time) or worker (next in line).
From its first model call until it is final, a job carries progress, updated every few seconds: model_calls, input_tokens (prompt-cache reads and writes included), output_tokens (reasoning included), estimated_eur and updated_at. estimated_eur is an estimate of the model cost so far, not a charge: the tokens at the job's prices, up to its hold, without fees; the job is charged when it ends (charged_eur), and the estimate is null when its model has no price. A job put back in the queue after a lost worker counts its earlier attempts too. Otherwise progress is null; a finished job's figures are charged_eur and outputs.budget.
Once the model has rendered the facts of every part, and until the job is final, GET /jobs/{id}/preview returns them in Turtle (gzip-encoded when the client accepts it): each part's facts as rendered, not yet merged across parts nor checked, without provenance. The job's result replaces them. Before then, and once the job is final, it answers 404 preview_not_found; so does a run whose rendered facts are too large to preview.
3. Download the graphs¶
curl -o facts.ttl -H "Authorization: Bearer $ONTOCAST_KEY" \
"$ONTOCAST_API/jobs/$JOB_ID/result"
curl -o ontology.ttl -H "Authorization: Bearer $ONTOCAST_KEY" \
"$ONTOCAST_API/jobs/$JOB_ID/result?graph=ontology"
In Python¶
The same three steps with httpx:
import os
import time
import httpx
api = httpx.Client(
base_url="https://api.growgraph.dev/ontocast",
headers={"Authorization": f"Bearer {os.environ['ONTOCAST_KEY']}"},
timeout=120,
)
with open("paper.pdf", "rb") as f:
response = api.post("/process", files={"file": f})
response.raise_for_status()
job = response.json()["jobs"][0]
while job["status"] not in ("COMPLETE", "ERROR", "ABORTED"):
time.sleep(15)
job = api.get(f"/jobs/{job['job_id']}").json()
if job["status"] == "COMPLETE":
facts = api.get(f"/jobs/{job['job_id']}/result")
with open("facts.ttl", "wb") as f:
f.write(facts.content)
else:
print(job["status"], job["error"])
After a quiet period
When the platform has been idle it starts up on the first request, answering 503 waking with a Retry-After header for a short while. A client that retries those keeps working through it.