Skip to content

API Reference — Go

Module github.com/muthuishere/toolnexus/golang (Go 1.23). See the combined API Reference for every symbol shown in eight-language synced tabs.

  • CreateToolkit(ctx context.Context, opts Options) (*Toolkit, error)
  • Options fields: McpConfig, SkillsDir, Skills, SkillProvider, SkillsFilter, SkillSampleLimit, Builtins, Agents, ExtraTools, WaitFor.
  • Equivalents: createToolkit (js) · create_toolkit (py) · Toolkit.create (java) · Toolkit.CreateAsync (c#) · Toolnexus.create_toolkit (elixir).
  • LoadSkills(dirs ...string) *SkillSource — back-compat variadic.
  • LoadSkillsWith(opts LoadSkillsOptions) *SkillSource
  • ListSkills(opts LoadSkillsOptions) *SkillInventory — .Skills, .Skipped (SkillSkip.Reason; constants SkipMissingName, SkipMalformed, SkipDuplicateName, SkipUnreadable).
  • SkillDef{ Name, Description, Content, Resources, Base }
  • LoadSkillsOptions{ Dirs, Skills, Filter, SampleLimit }
  • SkillProvider func(context.Context) ([]SkillDef, error) (on Options).
  • Equivalents: loadSkills / listSkills (js) · load_skills / list_skills (py) · SkillSource.loadWith / listSkills (java) · SkillSource.LoadWith / ListSkills (c#) · Toolnexus.Skill.load / Toolnexus.Skill.list (elixir).
  • LoadMcp(config any) (*McpSource, error)
  • tk.ToOpenAI() · tk.ToAnthropic() · tk.ToGemini()
  • CreateClient(opts ClientOptions) *Client → client.Ask(ctx, prompt, tk, id).

Tools you build — native, HTTP, built-ins

Section titled “Tools you build — native, HTTP, built-ins”
  • NativeTool(name, description, schema, fn) · NativeToolReflect[T](name, description, fn) — schema from struct json tags.
  • HTTPTool(opts HTTPToolOptions) — { Name, Description, Method, URL, Headers, Query, Body, ResultMode, Timeout }; Timeout ms (0 ⇒ 30000).
  • Builtins toggle → ten built-ins: bash · read · write · edit · grep · glob · webfetch · question · apply_patch · todowrite.
  • Equivalents: defineTool / httpTool (js) · define_tool / http_tool (py) · NativeTool.of / HttpTool.of (java) · NativeTool.Of / HttpTool.Of (c#) · Toolnexus.Native.define_tool / Toolnexus.Http.tool (elixir).
  • agents.New(name, agents.Spec{Does, Tools, Soul, SoulFile, Team, Budget, Model, WaitFor}) *Agent.
  • (a *Agent) Run(agents.Options{LLM: ...}, prompt) (TaskResult, *Runtime) — .Status, .Text, .TotalTokens.
  • (a *Agent) AsTool(agents.Options) tn.Tool · agents.ComposeSoul(dir) (soul, found).
  • Equivalents: agents.agent / .run / .asTool / composeSoul (js) · agent (py) · Agents.agent (java/elixir) · new Agent (c#).
  • (tk *Toolkit) Serve(addr, ServeOptions{Client, A2A: *A2AConfig, OnTask, MCP, OnCall}) (*ServeHandle, error).
  • Agent{Card, Headers, Timeout, PollEvery} + Options{Agents: []Agent} / tk.AddAgent(ctx, cardURL, opts).
  • Equivalents: tk.serve / tk.addAgent (js) · serve / add_agent (py) · serve / addAgent (java) · ServeAsync / AddAgentAsync (c#) · Toolkit.serve / Toolkit.add_agent (elixir).
  • WaitFor field on Options — func(Request) (Answer, error).
  • Request{ID, Kind, Prompt, URL, Data, ExpiresAt} · Answer{ID, Ok, Data, Reason}.
  • Pending(req Request) ToolResult · AuthRequired(url, prompt) ToolResult · PendingOf(result) *Request.
  • Equivalents: waitFor / pending / authRequired / pendingOf (js) · wait_for / pending (py) · waitFor / ToolResult.pending (java) · WithWaitFor / ToolResult.Pending (c#) · wait_for / ToolResult.pending? (elixir).

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

  • LoadMediaStyle(path string) (MediaStyle, error)
  • CreateMedia(styles []MediaStyle, opts MediaOptions) *Media — a verb resolves to the first style that declares it.
  • MediaOptions{ OnProgress func(MediaProgress), HTTPClient *http.Client } — MediaProgress{ Verb, JobID, Status } after every poll; HTTPClient nil ⇒ http.DefaultClient.
  • Verbs, each (ctx context.Context, in XInput) (MediaResult, error): Image(ImageInput{ Prompt, Width, Height, AspectRatio, Seed, ProviderOptions }) · Video(VideoInput{ Prompt, Image, Seconds, AspectRatio, ProviderOptions }) · Speech(SpeechInput{ Text, Voice, ProviderOptions }) · Transcribe(TranscribeInput{ Audio, ProviderOptions }) · CloneVoice(CloneVoiceInput{ Name, Samples, ProviderOptions }) · Talking(TalkingInput{ Image, Audio, ProviderOptions }).
  • Zero value = unset: a 0 or "" field is not sent. To send a literal zero (e.g. seed: 0), use Generate with an explicit args map.
  • (m *Media) Generate(ctx, verb string, args map[string]any, providerOptions map[string]any) (MediaResult, error) — the raw call. (m *Media) Supports(verb string) bool.
  • MediaResult{ Files []MediaFile, Text, JobID, Status } · MediaFile{ Type, MimeType, URL }.
  • (m *Media) Tools() []Tool (source "media"), or Options.Media.
  • RunResult.Files []RunFile — { Type, MimeType, URL, Data, Name, From, CallID }, in call order; the same parts are on RunResult.ToolCalls[i].Parts.
  • Errors: the function face returns an error whose Error() is the exact §7G message; cancelling ctx returns the context error. A media tool never errors (IsError: true).
  • Equivalents: createMedia (js) · create_media (py) · Media.create (java) · Media.Create (c#) · Toolnexus.Media.new (elixir) · toolnexus.media/create-media (clojure) · create_media (rust).