Skip to content

Client Kit Reference

The Flexus Client Kit (flexus-client-kit) is the Python SDK for building Flexus bots. It handles communication with the backend, tool registration, event handling, and integrations.

Installation

Terminal window
pip install flexus-client-kit

ckit_bot_exec

RobotContext, event handlers, main loop patterns. View Reference

ckit_cloudtool

Tool definitions, WaitForSubchats, NeedsConfirmation. View Reference

ckit_kanban

Kanban board operations, task creation and management. View Reference

ckit_ask_model

Bot activation, subchats, message creation. View Reference

Module Overview

ModulePurpose
ckit_bot_execCore bot execution, RobotContext, event handlers
ckit_cloudtoolTool definitions and call handling
ckit_kanbanKanban board operations
ckit_ask_modelLLM interactions, subchats
ckit_clientGraphQL client for Flexus API
ckit_bot_installMarketplace registration
ckit_scheduleSchedule definitions
ckit_shutdownGraceful shutdown handling
ckit_mongoMongoDB credential fetching

Integrations

ModulePurpose
fi_pdocPolicy document CRUD
fi_mongo_storePersonal MongoDB storage
fi_slackSlack messenger integration
fi_discord2Discord messenger integration
fi_gmailGmail integration
fi_reportPDF report generation
fi_widgetUI widget rendering

Integrations Reference

Basic Usage Pattern

import asyncio
from flexus_client_kit import ckit_client, ckit_bot_exec, ckit_cloudtool, ckit_shutdown
from mybot import mybot_install
BOT_NAME = "mybot"
BOT_VERSION = "1.0.0"
MY_TOOL = ckit_cloudtool.CloudTool(
strict=True,
name="my_tool",
description="Does something",
parameters={"type": "object", "properties": {...}, "required": [...], "additionalProperties": False}
)
TOOLS = [MY_TOOL]
async def main_loop(fclient, rcx):
setup = ckit_bot_exec.official_setup_mixing_procedure(
mybot_install.mybot_setup_schema,
rcx.persona.persona_setup
)
@rcx.on_tool_call(MY_TOOL.name)
async def handle(toolcall, args):
return "Result"
while not ckit_shutdown.shutdown_event.is_set():
await rcx.unpark_collected_events(sleep_if_no_work=10.0)
def main():
scenario_fn = ckit_bot_exec.parse_bot_args()
fclient = ckit_client.FlexusClient(
ckit_client.bot_service_name(BOT_NAME, BOT_VERSION),
endpoint="/v1/jailed-bot"
)
asyncio.run(ckit_bot_exec.run_bots_in_this_group(
fclient,
marketable_name=BOT_NAME,
marketable_version_str=BOT_VERSION,
bot_main_loop=main_loop,
inprocess_tools=TOOLS,
scenario_fn=scenario_fn,
install_func=mybot_install.install,
))
if __name__ == "__main__":
main()

Environment Variables

VariableRequiredDescription
FLEXUS_API_BASEURLYesBackend URL (e.g., https://flexus.team/)
FLEXUS_API_KEYYesYour API key
FLEXUS_WORKSPACENoDefault workspace ID