Skip to content

API Reference — Java

Artifact io.github.muthuishere:toolnexus (Java 21). See the combined API Reference for every symbol shown in eight-language synced tabs.

  • Toolkit.create(Toolkit.Options opts)
  • Options builder: .mcpConfig, .skillsDir, .skills, .skillProvider, .skillsFilter, .skillSampleLimit, .builtins, .agents, .extraTools, .waitFor.
  • Equivalents: createToolkit (js) · create_toolkit (py) · CreateToolkit (go) · Toolkit.CreateAsync (c#) · Toolnexus.create_toolkit (elixir).
  • SkillSource.load(String... dirs) — back-compat.
  • SkillSource.loadWith(SkillSource.LoadOptions opts)
  • SkillSource.listSkills(LoadOptions opts) -> SkillInventory — .skills, .skipped (SkillSkip.reason; constants SkillSkip.MISSING_NAME, MALFORMED, DUPLICATE_NAME, UNREADABLE).
  • new SkillSource.SkillDef(name, description, content[, resources, base])
  • LoadOptions builder: .dirs, .skills, .filter, .sampleLimit.
  • skillProvider is a Supplier<List<SkillDef>>.
  • Equivalents: loadSkills / listSkills (js) · load_skills / list_skills (py) · LoadSkillsWith / ListSkills (go) · SkillSource.LoadWith / ListSkills (c#) · Toolnexus.Skill.load / Toolnexus.Skill.list (elixir).
  • McpSource.load(config)
  • Adapters.toOpenAI(tk) · toAnthropic(tk) · toGemini(tk)
  • Client.create(Client.Options) → client.ask(prompt, tk).

Tools you build — native, HTTP, built-ins

Section titled “Tools you build — native, HTTP, built-ins”
  • NativeTool.of(name, description, schema, fn) — overload takes (args, ToolContext).
  • HttpTool.of(HttpTool.Options) — { name, description, method, url, headers, query, body, resultMode, timeout }; timeout Long ms.
  • .builtins(...) toggle → ten built-ins: bash · read · write · edit · grep · glob · webfetch · question · apply_patch · todowrite. (BuiltinTools.create() / .select(cfg).)
  • Equivalents: defineTool / httpTool (js) · define_tool / http_tool (py) · NativeTool / HTTPTool (go) · NativeTool.Of / HttpTool.Of (c#) · Toolnexus.Native.define_tool / Toolnexus.Http.tool (elixir).
  • Agents.agent(name, new Agents.AgentSpec().does(...).tools(...).soulFile(...).team(...).budget(...)).
  • Agents.Agent.run(RuntimeOptions, prompt): TaskResult — .status(), .text(), .totalTokens().
  • Agents.Agent.asTool(RuntimeOptions): Tool · Agents.composeSoul(Path): ComposedSoul.
  • Equivalents: agents.agent / .run / .asTool / composeSoul (js) · agent (py) · agents.New (go) · new Agent (c#) · Agents.agent (elixir).
  • tk.serve(addr, new Toolkit.ServeOptions().client(llm).a2a(new A2AServer.A2AConfig()...)).
  • A2A.agent(cardUrl) + Toolkit.Options().agents(List<A2A.Agent>) / tk.addAgent(cardUrl).
  • Equivalents: tk.serve / tk.addAgent (js) · serve / add_agent (py) · Serve / AddAgent (go) · ServeAsync / AddAgentAsync (c#) · Toolkit.serve / Toolkit.add_agent (elixir).
  • Options.waitFor(Function<Request, Answer>) (toolkit option).
  • record Request(id, kind, prompt, url, data, expiresAt) · record Answer(id, ok, data, reason).
  • ToolResult.pending(Request) · ToolResult.authRequired(url[, prompt]) · ToolResult.pendingOf(result): Request.
  • Equivalents: waitFor / pending / authRequired / pendingOf (js) · wait_for / pending (py) · WaitFor / Pending (go) · WithWaitFor / ToolResult.Pending (c#) · wait_for / ToolResult.pending? (elixir).

Guide: Media generation · recipe: Generate images, video and speech · SPEC §7G.

  • Media.createMedia(MediaClient... clients) · Media.createMedia(List<MediaClient> clients) (alias Media.create) — a verb goes to the first client whose supports(verb) is true and falls through to the next only on unavailable; an empty list throws media: no clients.
  • Named clients, each with () and (Media.Config config) constructors — API (key from the env var at call time): OpenAIMediaClient (OPENAI_API_KEY) · OpenRouterMediaClient (OPENROUTER_API_KEY) · ElevenLabsMediaClient (ELEVENLABS_API_KEY) · FalMediaClient (FAL_API_KEY) · A2EMediaClient (A2E_API_KEY); CLI: GrokMediaClient · CodexMediaClient.
  • new Media.Config() fluent: .model(String) · .models(Map<String,String>) (per verb) · .key(String) · .url(String) · .command(String | List<String>) · .loop(Media.Loop) · .gather(Media.Gather) · .httpClient(java.net.http.HttpClient).
  • new Media.Loop().intervalMs(long).timeoutMs(long).onProgress(Consumer<Media.Progress>) — Progress(verb, client, jobId, status, elapsedMs).
  • new Media.Gather().mode("url" | "download" | "inline").dir(String).maxBytes(long).keep(boolean) — sets which of MediaFile.url / path / data you get.
  • Verbs (blocking), each MediaResult x(XInput in) and MediaResult x(XInput in, LlmClient.CancelToken cancel): image(ImageInput(prompt, width, height, aspectRatio, seed, providerOptions)) · video(VideoInput(prompt, image, seconds, aspectRatio, providerOptions)) · speech(SpeechInput(text, voice, providerOptions)) · music(MusicInput(prompt, seconds, instrumental, lyrics, providerOptions)) · transcribe(TranscribeInput(audio, language, providerOptions)) · cloneVoice(CloneVoiceInput(name, samples, providerOptions)) · talk(TalkInput(image, audio, text, voice, providerOptions)). Each record has a short constructor with only the required args; null fields are not sent.
  • generate(String verb, Map<String,Object> args) · generate(verb, args, Media.Ctx ctx) · generate(verb, args, Map<String,Object> providerOptions, LlmClient.CancelToken cancel) · supports(verb).
  • Media.MediaResult(List<MediaFile> files, String text, String jobId, String status) · Media.MediaFile(type, mimeType, url, path, data) · MediaFile.ofUrl(type, mimeType, url).
  • interface MediaClient — implement name(), supports(String verb) and the verbs you serve: image | video | speech | music | transcribe | cloneVoice | talk(Map<String,Object> args, Media.Ctx ctx) (the rest default to unsupported); optional args(verb): List<Media.ArgSpec> (ArgSpec(name, required), null = every canonical arg). Media.Ctx carries cancelled, deadline, progress, providerOptions.
  • media.tools(): List<Tool> (source "media"), or Toolkit.Options.media(media).
  • RunResult.files: List<LlmClient.RunFile> — RunFile(type, mimeType, url, data, from, callId, name), in call order. Only image parts are sent to the model; other files reach it as the tool’s text output.
  • Errors: Media.MediaException (unchecked; status() failed | timeout | cancelled | unavailable, jobId(), message is the exact §7G string) · Media.MediaUnavailableException (status unavailable; throw it from your own client to trigger fall-through). A media tool never throws (isError).
  • Advanced: Media.styleMediaClient(Media.loadMediaStyle(String path)) / styleMediaClient(style, Media.Config) — a provider described in JSON (Media.Style.parse(json), Media.Style.of(map)).
  • Equivalents: createMedia (js) · create_media (py) · CreateMedia (go) · Media.Create (c#) · Toolnexus.Media.create (elixir) · toolnexus.media/create-media (clojure) · create_media (rust).