← All guides

Meta Model API

Connect Agent Nexus to Meta Muse Spark

Muse Spark (muse-spark-1.3) is OpenAI-SDK compatible and trained for tool loops. Expose Agent Nexus as a function tool, or add the MCP server to the agent harness running Muse Spark.

  1. 1. Get a Meta Model API key

    Sign up at dev.meta.ai, create a key and export it. Base URL: https://api.meta.ai/v1.

    export MODEL_API_KEY=...
  2. 2. Option A — harness with MCP (OpenCode, Goose, Roo…)

    Pick Muse Spark as the model in your harness, then add Agent Nexus as a remote MCP server. Example for OpenCode (opencode.json):

    {
      "mcp": {
        "agent-nexus": {
          "type": "remote",
          "url": "https://agentnexus.app/mcp",
          "enabled": true
        }
      }
    }
  3. 3. Option B — direct API with a function tool

    Declare a discover tool, let Muse Spark call it, and answer the call with the Agent Nexus HTTP API (no key needed for reads).

    import json, os, urllib.parse, urllib.request
    from openai import OpenAI
    
    client = OpenAI(base_url="https://api.meta.ai/v1", api_key=os.environ["MODEL_API_KEY"])
    tools = [{"type": "function", "function": {
      "name": "discover_capabilities",
      "description": "Find a callable API/MCP/CLI for a need, with live health.",
      "parameters": {"type": "object", "properties": {"need": {"type": "string"}}, "required": ["need"]}}}]
    
    def discover(need):
        url = "https://agentnexus.app/api/public/discover?need=" + urllib.parse.quote(need)
        with urllib.request.urlopen(url) as r:
            return r.read().decode()
    
    messages = [{"role": "user", "content": "Find an API to send transactional email."}]
    resp = client.chat.completions.create(model="muse-spark-1.3", messages=messages, tools=tools)
    call = resp.choices[0].message.tool_calls[0]
    messages += [resp.choices[0].message, {"role": "tool", "tool_call_id": call.id,
      "content": discover(json.loads(call.function.arguments)["need"])}]
    print(client.chat.completions.create(model="muse-spark-1.3", messages=messages).choices[0].message.content)

Test it

Ask the assistant: "Use Agent Nexus to find an API that sends transactional email, and show its health." It should call discover_capabilities and return endpoints with live health.

Reads need no key. For 1,000 calls/day, get a free key. Official docs: https://dev.meta.ai/docs/quickstart