# Function calling without MCP

If your agent framework uses function calling instead of MCP, define a tool and execute it against the REST API. Ready-made definitions are served at https://extractivio.com/agent-tools.json.

## Tool definition, Anthropic format

```json
{
  "name": "convert_statement",
  "description": "Extract transactions from a text-based PDF bank or credit card statement. Returns date (ISO), description, signed amount (negative = money out) and running balance per transaction, plus a balance check. Provide a public https URL. Scanned PDFs are not supported.",
  "input_schema": {
    "type": "object",
    "properties": {
      "file_url": { "type": "string", "description": "Public https URL of the PDF." },
      "date_order": { "type": "string", "enum": ["dmy", "mdy"], "description": "mdy for US statements, dmy elsewhere. Omit to auto-detect." },
      "format": { "type": "string", "enum": ["json", "csv", "xero", "qbo", "ofx", "qfx", "qif"], "description": "json unless the user asked for a file." }
    },
    "required": ["file_url"]
  }
}
```

## Tool definition, OpenAI format

```json
{
  "type": "function",
  "function": {
    "name": "convert_statement",
    "description": "Extract transactions from a text-based PDF bank or credit card statement. Returns date (ISO), description, signed amount (negative = money out) and running balance per transaction, plus a balance check. Provide a public https URL. Scanned PDFs are not supported.",
    "parameters": {
      "type": "object",
      "properties": {
        "file_url": { "type": "string", "description": "Public https URL of the PDF." },
        "date_order": { "type": "string", "enum": ["dmy", "mdy"], "description": "mdy for US statements, dmy elsewhere. Omit to auto-detect." },
        "format": { "type": "string", "enum": ["json", "csv", "xero", "qbo", "ofx", "qfx", "qif"], "description": "json unless the user asked for a file." }
      },
      "required": ["file_url"]
    }
  }
}
```

## Executing the call

When the model calls the tool, your code makes the HTTP request and returns the body to the model.

```python
import os, requests

def convert_statement(file_url, date_order=None, format="json"):
    params = {"format": format}
    if date_order:
        params["date_order"] = date_order
    r = requests.post(
        "https://extractivio.com/api/v1/convert",
        params=params,
        headers={"Authorization": f"Bearer {os.environ['EXTRACTIVIO_KEY']}"},
        json={"file_url": file_url},
        timeout=90,
    )
    if r.status_code != 200:
        # Return the error to the model so it can explain it; do not raise.
        return r.text
    return r.text  # JSON for format=json, file content otherwise
```

Return errors to the model as text instead of raising. The error body has a `code` the model can act on; see [Errors](https://extractivio.com/docs/errors.md).

Keep the API key in your code's environment. Never include it in the tool definition or the prompt.

## If the file is not at a URL

Have your code read the file and send it as multipart or raw bytes; expose a tool that takes a local path or an attachment id that your code resolves. Do not ask the model to produce base64.

## OpenAPI

The full API is described at https://extractivio.com/openapi.json (OpenAPI 3.1). Frameworks that build tools from an OpenAPI document can load it directly; the operation ids are `convertStatement`, `getUsage` and `listConversions`.
