Astrology function calling with OpenAI, Claude, and Gemini
Wire RoxyAPI endpoints into OpenAI, Anthropic, or Gemini as function tools. Time to ship: 15 minutes.
Function calling is the manual, control-heavy path for letting an LLM call RoxyAPI. You hand-define tool schemas, route tool calls to the right endpoint, and ship the results back. MCP does this automatically, which is why MCP is the default. Use function calling when your model does not support MCP, when you need tight control over which tools are exposed, or when you are gluing RoxyAPI into an existing agent framework.
You probably want MCP instead
If you are on Claude Code, Cursor, Antigravity, Claude Desktop, or any MCP-compatible client, skip this guide. The MCP setup auto-discovers all 261+ RoxyAPI endpoints and requires zero tool schemas. Function calling is the fallback when MCP is not available.
If you are an AI coding agent reading this guide to write function-calling code, also fetch the site-level AGENTS.md playbook at https://roxyapi.com/AGENTS.md for tight per-endpoint body shapes you will encode as tool schemas.
Function calling
MCP
Setup
You write tool schemas, or auto-generate from OpenAPI
Zero config, agents discover tools at runtime
Control
You pick exactly which tools to expose
All tools available
Compatibility
Any model with tool-use support
Requires MCP-compatible client
Best for
Production apps with tight control
Prototyping, AI assistants, agent frameworks
What you can build with this
AI chatbots that call RoxyAPI from OpenAI, Anthropic, or Gemini
Agents where only specific RoxyAPI endpoints are exposed (least-privilege tool sets)
Serverless functions that route a user question to the right RoxyAPI call
Custom agent frameworks (LangChain, LlamaIndex, AG2) with RoxyAPI as a tool
Multi-provider apps that keep the same tool definitions across LLMs
When the model returns a tool call, route it to the right RoxyAPI endpoint. Pick your preferred call style.
bash
# For reference. The tool-call executor below uses fetch, but this is the underlying shape.
curl "https://roxyapi.com/api/v2/astrology/horoscope/aries/daily" \
-H "X-API-Key: $ROXY_API_KEY"
curl -X POST https://roxyapi.com/api/v2/tarot/draw \
-H "X-API-Key: $ROXY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"count": 3}'
import os
from roxy_sdk import create_roxy
roxy = create_roxy(os.environ['ROXY_API_KEY'])
def execute_tool(name, args):
if name == 'get_daily_horoscope':
return roxy.astrology.get_daily_horoscope(sign=args['sign'])
if name == 'draw_tarot_cards':
return roxy.tarot.draw_cards(count=args['count'])
if name == 'get_birth_chart':
return roxy.astrology.generate_natal_chart(**args)
raise ValueError(f'unknown tool: {name}')
csharp
using RoxyApi;
using Microsoft.Kiota.Abstractions; // for the Date and Time types
using System.Text.Json;
var roxy = new RoxyClient(Environment.GetEnvironmentVariable("ROXY_API_KEY")!);
// args is the JSON arguments object the model returns with each tool call
async Task<object?> ExecuteTool(string name, JsonElement args) => name switch
{
"get_daily_horoscope"
=> await roxy.Astrology.Horoscope[args.GetProperty("sign").GetString()!].Daily.GetAsync(),
"draw_tarot_cards"
=> await roxy.Tarot.Draw.PostAsync(new() { Count = args.GetProperty("count").GetInt32() }),
// get_birth_chart maps to roxy.Astrology.NatalChart.PostAsync(new() { Date = new Date(y, m, d), Time, Latitude, Longitude, Timezone })
_ => throw new ArgumentException($"unknown tool: {name}"),
};
Every RoxyAPI domain also publishes its own OpenAPI spec, which keeps a generated tool list to the one domain you need. Parse it to generate tool schemas instead of writing them by hand. To read a contract rather than import one, query the combined spec with the jq recipe in AGENTS.md.
Available domains: astrology, vedic-astrology, forecast, human-design, chinese-astrology, feng-shui, mesoamerican-astrology, vastu, numerology, kabbalah, tarot, biorhythm, ayurveda, iching, crystals, dreams, angel-numbers, location. Use openapi-typescript or any OpenAPI-to-tool-schema generator.
Gotchas
One JSON Schema, three wrappers. OpenAI takes { type: 'function', name, description, parameters }. Anthropic renames parameters to input_schema. Gemini takes it as parametersJsonSchema inside functionDeclarations[].
OpenAI: use the Responses API. Tool calls arrive as function_call items in response.output; answer each with a function_call_output carrying the same call_id.
Timezone accepts both shapes. IANA string ("America/New_York") or decimal (-5). Prefer IANA for DST correctness.
Geocode before chart endpoints. Natal chart, kundli, panchang, synastry need latitude, longitude, timezone. Add a search_cities tool and tell the model to call it first.
Tell the model to call a tool, not to guess. System prompt: "For horoscope, birth chart, human design, forecast, or any spiritual topic, always call a tool. Never answer from training data."
What to build next
The MCP setup is the zero-config alternative to this guide.
The AI readings guide turns a chart into a written reading with one call and one prompt.
The SDK docs cover typed calls for TypeScript, Python, PHP, C#, Go, Rust, and Dart.
The API reference lets you explore any endpoint before wiring a tool for it.
R
RosieYour AI guide to RoxyAPI
R
Hi, I am Rosie, your guide to the RoxyAPI insight tools.
Ask me to read your birth chart, pull a card, or map your numbers, and I will interpret what it means for you. Unlike most AIs, I never make the numbers up: every reading runs on real, verified calculations. Curious about the API, pricing, or docs instead? Ask me that too.