API Reference — Python
Package toolnexus (PyPI, Python ≥ 3.11). See the combined API Reference for every
symbol shown in eight-language synced tabs.
Toolkit
Section titled “Toolkit”create_toolkit(...) -> Toolkit(async)- Keyword args:
mcp_config,skills_dir,skills,skill_provider,skills_filter,skill_sample_limit,builtins,agents,extra_tools,wait_for. - Equivalents:
createToolkit(js) ·CreateToolkit(go) ·Toolkit.create(java) ·Toolkit.CreateAsync(c#) ·Toolnexus.create_toolkit(elixir).
Skills
Section titled “Skills”load_skills(dirs=None, *, skills=None, filter=None, sample_limit=0) -> SkillSourcelist_skills(dirs=None, *, skills=None) -> SkillInventory—.skills,.skipped(SkillSkip.reason:missing-name·malformed-frontmatter·duplicate-name·unreadable).SkillDef(name, content, description=None, resources=None, base=None)skill_providermay be sync or async.- Equivalents:
loadSkills/listSkills(js) ·LoadSkillsWith/ListSkills(go) ·SkillSource.loadWith/listSkills(java) ·SkillSource.LoadWith/ListSkills(c#) ·Toolnexus.Skill.load/Toolnexus.Skill.list(elixir).
MCP · Adapters · Client
Section titled “MCP · Adapters · Client”load_mcp(config) -> McpSource(async)to_openai(tk)·to_anthropic(tk)·to_gemini(tk)create_client(...) -> Client→await client.ask(prompt, tk).
Tools you build — native, HTTP, built-ins
Section titled “Tools you build — native, HTTP, built-ins”@tool/define_tool(fn, *, name?, description?, input_schema?)— schema inferred from type hints + docstring.http_tool(*, name, description, method, url, headers?, query?, body?, result_mode?, timeout?)—timeoutin seconds.builtinstoggle → ten built-ins:bash · read · write · edit · grep · glob · webfetch · question · apply_patch · todowrite.- Equivalents:
defineTool/httpTool(js) ·NativeTool/HTTPTool(go) ·NativeTool.of/HttpTool.of(java) ·NativeTool.Of/HttpTool.Of(c#) ·Toolnexus.Native.define_tool/Toolnexus.Http.tool(elixir).
Sub-agents & teams
Section titled “Sub-agents & teams”agent(name, *, does, uses?, soul?, soul_file?, team?, budget?, model?, wait_for?) -> Agent.await agent.run(prompt, *, llm={...}, ...) -> TaskResult—.status,.text,.total_tokens,.runtime.agent.as_tool(**rt_opts) -> Tool·compose_soul(dir) -> (soul, found)·Budget(...).- Equivalents:
agents.agent/.run/.asTool/composeSoul(js) ·agents.New(go) ·Agents.agent(java/elixir) ·new Agent(c#).
A2A — serve & remote agents
Section titled “A2A — serve & remote agents”await tk.serve(addr, *, client, a2a: A2AConfig, on_task?, mcp?, on_call?) -> ServeHandle.agent(card, *, headers?, timeout?, poll_every?)+create_toolkit(agents=[...])/await tk.add_agent(card_url).- Equivalents:
tk.serve/tk.addAgent(js) ·Serve/AddAgent(go) ·serve/addAgent(java) ·ServeAsync/AddAgentAsync(c#) ·Toolkit.serve/Toolkit.add_agent(elixir).
Suspension & the human loop
Section titled “Suspension & the human loop”wait_for(toolkit option; callable(Request) -> Answer).Request(id, kind, prompt, url?, data?, expiresAt?)·Answer(id, ok, data?, reason?).pending(*, kind, prompt, url?, data?)·auth_required(url, prompt?)·pending_of(result).- Equivalents:
waitFor/pending/authRequired/pendingOf(js) ·WaitFor/Pending(go) ·waitFor/ToolResult.pending(java) ·WithWaitFor/ToolResult.Pending(c#) ·wait_for/ToolResult.pending?(elixir).
Media generation
Section titled “Media generation”Guide: Media generation · recipe: Generate images, video and speech · SPEC §7G.
create_media(clients: MediaClient | list[MediaClient]) -> Media— a verb goes to the first client whosesupports(verb)is true; onlyMediaUnavailableErrorfalls through to the next one.- Built-in clients, each
X(config: MediaConfig | dict | None = None, **kw):A2EMediaClient(A2E_API_KEY) ·ElevenLabsMediaClient(ELEVENLABS_API_KEY) ·OpenAIMediaClient(OPENAI_API_KEY) ·OpenRouterMediaClient(OPENROUTER_API_KEY) ·FalMediaClient(FAL_API_KEY) — and the CLI clientsGrokMediaClient(grok) ·CodexMediaClient(codex). MediaConfig(model, models: dict[str, str], key, url, command: str | list[str], loop: LoopConfig, gather: GatherConfig, http_client: MediaTransport)·LoopConfig(interval_ms, timeout_ms, on_progress)·GatherConfig(mode: "url" | "download" | "inline", dir, max_bytes, keep)—loop/gatheralso take dicts (snake_case or camelCase keys).keydefaults to the env var read at call time;timeout_ms600000;gather.modedefaultdownload(style clientsurl) into<tmp>/toolnexus-media,max_bytes100 MiB.on_progress({"verb", "client", "jobId", "status", "elapsedMs"})may be sync or async.MediaTransport— blockingrequest(method, url, headers, body, timeout) -> (status, body[, headers]), run in a worker thread; it must not follow redirects (the client does, under §7G.8). DefaultUrllibMediaTransport.- Verbs (all
async, returnMediaResult; each also takesdeadline=,progress=,provider_options=):image(prompt, *, width, height, aspect_ratio, seed)·video(prompt, *, image, seconds, aspect_ratio)·speech(text, *, voice)·music(prompt, *, seconds, instrumental, lyrics)·transcribe(audio, *, language)·clone_voice(name, samples)·talk(image, *, audio, text, voice). File inputs take a URL or a local path;Nonearguments are not sent. await media.generate(verb, args=None, provider_options=None, *, deadline=None, progress=None, ctx=None)— the raw call;verbis the canonical name ("cloneVoice", not"clone_voice").media.supports(verb) -> bool.MediaResult(files: list[MediaFile], text, job_id, status)·MediaFile(type, mime_type, url, path, data);.to_dict()gives the canonical camelCase shape.MediaClient(protocol):name,supports(verb), optionalargs(verb) -> [{"name", "required"}]andasync image(args, ctx)…talk(args, ctx).BaseMediaClientroutes all seven to oneasync generate(verb, args, ctx: MediaContext).MediaContext(deadline, progress, provider_options).media.tools() -> list[Tool]—generate_image·generate_video·generate_speech·generate_music·transcribe_audio·clone_voice·talking_video(source"media"), one per verb any client supports; orcreate_toolkit(media=media). Only image parts are sent back to the model.RunResult.files— list of dicts{type, mimeType, url?, data?, from, callId}, in call order; the same parts are ontool_calls[i]["parts"].- Errors: the function face raises
MediaError(str(e)is the exact §7G message;.status,.job_id);MediaUnavailableErroris itsunavailablesubclass. A media tool never raises (is_error=True).asyncio.CancelledErroralways propagates, from the function face and the tool face alike. - Advanced:
style_media_client(style, config=None)/StyleMediaClientturn a JSON style into a client;load_media_style(path) -> dictreads one. - Equivalents:
createMedia(js) ·CreateMedia(go) ·Media.create(java) ·Media.Create(c#) ·Toolnexus.Media.create(elixir) ·toolnexus.media/create-media(clojure) ·create_media(rust).