The GoGo Agent API

The API serves requests through Bittensor's Subnet 20 to enable tool-based workflows.

The API has a single endpoint for all queries - https://api.gogoagent.ai/query_subnet

OpenAI Chat Completions Example
Python Example
Curl Example

Parameters:

Below are the available parameters for interfacing with the API:

prompt - a simple string with the user query [Deprecation warning in favor of messages]

Example:

"What do dogs eat?"

messages - an array of role-based content dicts for user, assistant and system

Example:

[
  {"role": "user", 
   "content": "Need help calculating the tip, what is 10% tip on a bill totalling $100"}, 
  {"role": "assistant", 
   "content": "Using a calculator, I observed a tip amount of 10.0 dollars, please let the user know in a kind response."}, 
  {"role": "user", 
   "content": "What's the answer?"}
]

tools - an array of tool dicts with name, description and arguments

Example:

[
  {"name": "tip_calculator", 
   "description": "calculate tip for a total amount", 
   "arguments": {
     "bill_amount": {
        "required": True, "type": "number", 
        "description": "the bill amount in dollars"}, 
     "tip_percent": {
        "required": True, "type": "number", 
        "description": "the tip percentage as a whole number"}
  }}
]

datas - an array of data dicts with source and content

Example:

[
  {"source": "wikipedia1", "content": "Dogs eat apples"},
  {"source": "wikipedia2", "content": "Dogs hate meat"}
]

files - an array of file dicts with type and content

Example:

[
  {"type": "Image", "content": "ImageString"},
  {"type": "Text", "content": "Dogs love cats"}
]

Example with OpenAI Chat Completions:

Here’s a simple python example using OpenAI Chat Completions with custom tools:

import openai

# Initialize the OpenAI client
client = openai.OpenAI(
    api_key="API KEY GOES HERE",
    base_url="https://api.gogoagent.ai/v1"
)

# Setup the messages / prompt
messages = [
  {"role": "user",
   "content": "I need help calculating the tip; what is 10% tip on a bill totalling $210"}
]

# Define the tools
tools = [
  {
    "name": "tip_calculator", 
    "description": "Calculate the tip amount",
    "arguments": {
      "bill_amount": {
        "required": True, "type": "number",
        "description": "the bill amount in dollars"
      },
      "tip_percent": {
        "required": True, "type": "number",
        "description": "the tip percentage as a whole number",
      }
    }
  },
  {
    "name": "calculator_for_summation", 
    "description": "Calculate the sum of two numbers",
    "arguments": {
      "num1": {
        "required": True, "type": "number",
        "description": "the first number for summation"
      },
      "num2": {
        "required": True, "type": "number",
        "description": "the second number for summation"
      }
    }
  }
]

# Send the request
completion = client.chat.completions.create(
    model="BitAgent/GoGoAgent",
    messages=messages,
    tools=tools,
)

# Print the response
print(completion.choices[0].message)

Example in Python:

Here’s a similar example using python and requests:

import json
import requests
# Define the tools
tip_calc_tool = {
  "name": "tip_calculator",
  "description": "Calculate the tip amount",
  "arguments": {
    "bill_amount": {
      "required": True, "type": "number",
      "description": "the bill amount in dollars"
    },
    "tip_percent": {
      "required": True, "type": "number",
      "description": "the tip percentage as a whole number"
    }
  }
}
# Define a summation calculator
sum_calc_tool = {
  "name": "sum_calculator",
  "description": "Calculate the sum of two numbers",
  "arguments": {
    "num1": {
      "required": True, "type": "number",
      "description": "the first number for summation"
    },
    "num2": {
      "required": True, "type": "number",
      "description": "the second number for summation"
    }
  }
}
tools = [tip_calc_tool, sum_calc_tool]
# Setup the messages / prompt
messages = [
  {"role": "user",
   "content": "I need help calculating the tip; what is 10% tip on a bill totalling $210"}
]
# Send the request to the API
api_endpoint = "https://api.gogoagent.ai/v1/chat/completions"
hdrs = {"Content-Type": "application/json",
        "Authorization": "API KEY GOES HERE"}
data = {"messages": messages, "tools": tools}
result = requests.post(api_endpoint, headers=hdrs, json=data)
# print out the results
print(result)
print(result.json())

Example in Curl:

And for fun, here’s the same query using curl (meaning you can use any libcurl-based library):

curl -X POST https://api.gogoagent.ai/query_subnet \
     -H "Content-Type: application/json" \
     -H "Authorization: API KEY GOES HERE" \
     -d '{
           "messages": [
             {
               "role": "user",
               "content": "Need help calculating the tip, what is 10% tip on a bill totalling $100"
             }
           ],
           "tools": [
             {
               "name": "tip_calculator",
               "description": "Calculate the tip amount",
               "arguments": {
                 "bill_amount": {
                   "required": true,
                   "type": "number",
                   "description": "the bill amount in dollars"
                 },
                 "tip_percent": {
                   "required": true,
                   "type": "number",
                   "description": "the tip percentage as a whole number"
                 }
               }
             }
           ]
         }'