Backoffice API¶
kavalai.backoffice is the FastAPI service behind the management UI. It
exposes agents, sessions, runs, metrics, model-call statistics and RAG indexes,
and the project service that scopes them.
Copyright 2026 OÜ KAVAL AI (registry code 17393877)
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- kavalai.backoffice.server.get_backoffice_session()[source]¶
Context manager to provide a session for the backoffice database. Handles connection errors gracefully.
- kavalai.backoffice.server.get_project_session(project: Project)[source]¶
Context manager to provide a session for a specific project’s agent database. Handles connection errors gracefully.
- async kavalai.backoffice.server.assert_is_owner(session: AsyncSession, request: Request, project_id: UUID)[source]¶
- async kavalai.backoffice.server.assert_is_member(session: AsyncSession, request: Request, project_id: UUID)[source]¶
- async kavalai.backoffice.server.get_project_and_assert_access(request: Request, project_id: UUID) Project[source]¶
Fetch project and assert user is a member.
- async kavalai.backoffice.server.set_active_project(project_id: UUID, request: Request)[source]¶
-
async kavalai.backoffice.server.projects_create(request: Request, data: dict =
Body(PydanticUndefined))[source]¶
- async kavalai.backoffice.server.projects_get_by_id(project_id: UUID, request: Request)[source]¶
-
async kavalai.backoffice.server.projects_update(project_id: UUID, request: Request, data: dict =
Body(PydanticUndefined))[source]¶
- async kavalai.backoffice.server.projects_delete(project_id: UUID, request: Request)[source]¶
-
async kavalai.backoffice.server.users_create(request: Request, data: dict =
Body(PydanticUndefined))[source]¶
-
async kavalai.backoffice.server.users_update(user_id: UUID, request: Request, data: dict =
Body(PydanticUndefined))[source]¶
- async kavalai.backoffice.server.agents_get_by_id(project_id: UUID, agent_id: UUID, request: Request)[source]¶
-
async kavalai.backoffice.server.workflows_render_svg(request: Request, data: dict =
Body(PydanticUndefined))[source]¶ Render a workflow graph to an SVG diagram.
Accepts
{"workflow": {...}}(or a bare workflow dict) and returns animage/svg+xmldocument. The agents page uses this to show an agent’s workflow as a backend-generated diagram (replacing the client-side build).
- async kavalai.backoffice.server.agents_get_all(project_id: UUID, request: Request)[source]¶
Fetch all agents belonging to a specific project.
-
async kavalai.backoffice.server.agents_get_stats(project_id: UUID, request: Request, days: int =
7, agent_id: UUID | None =None)[source]¶ Fetch daily stats for agents in a specific project.
-
async kavalai.backoffice.server.agents_get_summary_stats(project_id: UUID, request: Request, agent_id: UUID | None =
None)[source]¶ Fetch summary stats (last 30 days) for agents in a specific project.
-
async kavalai.backoffice.server.agents_get_sessions(project_id: UUID, request: Request, agent_id: UUID | None =
None, search: str | None =None, start_date: datetime | None =None, end_date: datetime | None =None, limit: int =50, offset: int =0)[source]¶ Fetch session summaries for a specific project.
- async kavalai.backoffice.server.agents_get_session_details(project_id: UUID, session_id: UUID, request: Request)[source]¶
Fetch all details (messages, runs, tasks) for a specific session.
-
async kavalai.backoffice.server.projects_get_llm_call_stats(project_id: UUID, request: Request, call_type: str | None =
None, limit: int =50, offset: int =0)[source]¶ Fetch paginated LLM call stats for a specific project.
-
async kavalai.backoffice.server.projects_rag_query(project_id: UUID, request: Request, query_data: dict =
Body(PydanticUndefined))[source]¶ Execute a RAG query for a specific project.
- async kavalai.backoffice.server.projects_rag_stats(project_id: UUID, request: Request)[source]¶
Fetch RAG statistics for a specific project.
- async kavalai.backoffice.server.projects_train_pca(project_id: UUID, collection_name: str, request: Request)[source]¶
Trigger PCA training for a specific project and collection.
-
async kavalai.backoffice.server.projects_test_connection(project_id: str, request: Request, data: dict =
Body({}))[source]¶ Test connection to the project database.
- async kavalai.backoffice.server.projects_get_members(project_id: UUID, request: Request)[source]¶
-
async kavalai.backoffice.server.projects_add_member(project_id: UUID, request: Request, data: dict =
Body(PydanticUndefined))[source]¶
-
async kavalai.backoffice.server.projects_update_member(project_id: UUID, request: Request, data: dict =
Body(PydanticUndefined))[source]¶
- async kavalai.backoffice.server.projects_remove_member(project_id: UUID, user_id: UUID, request: Request)[source]¶
Copyright 2026 OÜ KAVAL AI (registry code 17393877)
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- class kavalai.backoffice.project_service.ProjectService(session_maker: async_sessionmaker[AsyncSession])[source]¶
Bases:
object- async get_project(project_id: UUID) Project | None[source]¶
- async delete_project(project_id: UUID) bool[source]¶