Skip to main content
LLM agents act through tools — JSON-schema-described functions the model can call. CreatorAudit ships a complete OpenAPI document, so you can generate those tool definitions instead of writing them by hand, then execute the calls the model picks.

The pattern

1

Fetch the contract

Download the OpenAPI spec from https://api.creatoraudit.com/v2/openapi.json (also linked from the API reference). It describes every endpoint, parameter, and response shape.
2

Generate tool schemas

Convert the operations you want to expose into your provider’s tool format. Each operation becomes one tool: the path and method are the call target; the parameters and request body become the input JSON schema. This works for Anthropic tool use, OpenAI function calling, and any generic function-calling runtime — they all consume JSON Schema.Start small. Expose a handful of read endpoints (/search, /overview, /accounts, /creators/top) before adding write endpoints (POST /accounts, POST /videos).
3

Execute calls with the bearer key

When the model calls a tool, issue the matching HTTP request with Authorization: Bearer YOUR_API_KEY, then return the JSON response to the model. Keep the key on your server — never expose it to the model’s context or to client-side code.

A minimal tool layer

The example below defines two read tools — search (calls GET /v2/search) and overview (calls GET /v2/overview) — and an executor that runs whichever tool the model picks. Responses are passed through verbatim, so you never hardcode fields that might drift.
import os
import httpx

BASE = "https://api.creatoraudit.com/v2"
API_KEY = os.environ["CREATORAUDIT_API_KEY"]  # keep server-side

# Tool schemas in Anthropic tool-use shape. OpenAI function calling uses the
# same JSON Schema under a "parameters" / "function" wrapper.
TOOLS = [
    {
        "name": "search",
        "description": "Search tracked accounts, creators, and videos by query.",
        "input_schema": {
            "type": "object",
            "properties": {
                "q": {"type": "string", "description": "Search query."},
                "limit": {"type": "integer", "minimum": 1, "maximum": 25},
            },
            "required": ["q"],
        },
    },
    {
        "name": "overview",
        "description": "Organization-level headline figures.",
        "input_schema": {
            "type": "object",
            "properties": {
                "period": {"type": "string", "description": "e.g. 7d, 30d, 90d."}
            },
        },
    },
]

# Map each tool to its HTTP call. Keep responses opaque — pass them through.
ROUTES = {
    "search": ("GET", "/search"),
    "overview": ("GET", "/overview"),
}


def execute_tool(name: str, args: dict) -> dict:
    method, path = ROUTES[name]
    headers = {"Authorization": f"Bearer {API_KEY}"}
    resp = httpx.request(method, f"{BASE}{path}", params=args, headers=headers)

    request_id = resp.headers.get("X-Request-ID")  # log for tracing

    if resp.status_code >= 400:
        # RFC 9457 problem details: application/problem+json
        problem = resp.json()
        return {
            "error": True,
            "status": resp.status_code,
            "code": problem.get("code"),
            "detail": problem.get("detail"),
            "request_id": request_id,
        }

    return resp.json()  # { "data": [...], "pagination": {...} } or an object
These calls go to the CreatorAudit API, not the docs MCP. Mintlify’s /mcp searches the documentation; to call the API as MCP tools instead, see Connect via MCP.

What to get right in the loop

Keep YOUR_API_KEY on the server. The model’s context, tool arguments, and any client-side code should never see it.
  • Paginate in a loop. Collection responses carry pagination.next_cursor and pagination.has_next. Pass cursor back with limit (1–200) and keep going until has_next is false. Don’t make the model manage cursors — handle it in your executor and return aggregated results.
  • Parse RFC 9457 errors. On any 4xx/5xx, the body is application/problem+json with status, title, detail, and a machine-readable code. Branch on status for control flow and on code for specific handling, then hand the model a structured error it can reason about.
  • Log X-Request-ID. Capture the header on every call — success or failure — so any request can be traced. Quote it when you contact support.
  • Use Idempotency-Key on writes. POST /accounts, POST /videos, and POST /creators accept an optional Idempotency-Key header. Set a stable key per logical action so retries from an agent loop don’t create duplicates.

Next