Genesis Arbitrage

Genesis Arbitrage · · 3 min read

Function calling

Function calling (also called tool use) is a mode in which a language model returns a tool name and JSON arguments instead of text. The model runs nothing itself: your code makes the request, the result goes back to the model, and it answers from that data.

How a call works

  1. The application sends the model tool descriptions: a name, a purpose and a JSON Schema for the arguments.
  2. The model needs data and returns, for example, funding_rates with the arguments {"coin": "TON"}.
  3. Your code validates the arguments, calls the API and sends the response back to the model.
  4. The model writes its answer from that data or calls the next tool.

Field names depend on the model's API. In the Claude API the schema goes in input_schema, the model replies with a tool_use block and you return the result in a tool_result block; in MCP the schema is called inputSchema.

A tool for Genesis API

A tool definition for funding rates in the Claude API format:

{
  "name": "funding_rates",
  "description": "A coin's funding rates by exchange (Genesis API)",
  "input_schema": {
    "type": "object",
    "properties": {
      "coin": {"type": "string", "description": "Ticker, e.g. TON"},
      "exchange": {"type": "string",
                   "description": "Exchanges, comma-separated"}
    },
    "required": ["coin"]
  }
}

An executor with an allowlist: the model can pick only known tools and parameters, and the key comes from the server's environment.

import os

import requests

API = "https://api.genesisarbitrage.com/v1"
TOOLS = {"funding_rates": ("/funding/rates", {"coin", "exchange"})}


def run_tool(name: str, args: dict) -> str:
    """Runs a model's call: known paths and parameters only."""
    if name not in TOOLS:
        return '{"error": "unknown tool"}'
    path, allowed = TOOLS[name]
    params = {k: v for k, v in args.items() if k in allowed}
    r = requests.get(
        API + path,
        headers={"X-API-Key": os.environ["GENESIS_API_KEY"]},
        params=params,
        timeout=10,
    )
    return r.text  # goes back to the model as the tool result

Safety

See also: OpenAPI, JSON, API key, Genesis API errors, Genesis API for AI agents, crypto market data for AI agents.

Questions and answers

Can a model buy a coin through function calling?

Only if you give it such a tool. Not through Genesis API: it returns data and places no orders. The decision to trade and the trade itself stay with a person.