API Reference

Tool Calling

Aniron implements the same tools / tool_choice / tool_calls shape as the OpenAI Chat Completions API. Any model in the catalog that supports function calling accepts this request format unchanged.

Defining tools

Pass an array of function definitions in tools. Each entry describes a function with a name, description, and a JSON Schema for its parameters:

POST /v1/chat/completions
{
  "model": "aniron/llama-3.1-70b",
  "messages": [
    { "role": "user", "content": "What's the weather in Lisbon?" }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get the current weather for a city.",
        "parameters": {
          "type": "object",
          "properties": {
            "city": { "type": "string" }
          },
          "required": ["city"]
        }
      }
    }
  ],
  "tool_choice": "auto"
}

tool_choice

Controls whether and how the model calls a tool:

  • "auto" — the model decides whether to call a tool. Default when tools is present.
  • "none" — the model never calls a tool, even if one is provided.
  • { "type": "function", "function": { "name": "get_weather" } } — forces a specific function call.

Reading the response

When the model decides to call a tool, content is null, finish_reason is "tool_calls", and message.tool_calls contains one entry per call, each with an id and a function.arguments string (JSON-encoded — parse it before use):

200 OK
{
  "id": "chatcmpl-8f3a1c2b9d4e",
  "object": "chat.completion",
  "model": "aniron/llama-3.1-70b",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_9kq2",
            "type": "function",
            "function": {
              "name": "get_weather",
              "arguments": "{\"city\":\"Lisbon\"}"
            }
          }
        ]
      },
      "finish_reason": "tool_calls"
    }
  ]
}

Returning tool results

Execute the function yourself, then send the result back as a role: "tool" message carrying the matching tool_call_id, alongside the assistant's tool call message from the previous turn:

POST /v1/chat/completions
{
  "model": "aniron/llama-3.1-70b",
  "messages": [
    { "role": "user", "content": "What's the weather in Lisbon?" },
    {
      "role": "assistant",
      "content": null,
      "tool_calls": [
        { "id": "call_9kq2", "type": "function", "function": { "name": "get_weather", "arguments": "{\"city\":\"Lisbon\"}" } }
      ]
    },
    {
      "role": "tool",
      "tool_call_id": "call_9kq2",
      "content": "{\"temp_c\":19,\"conditions\":\"partly cloudy\"}"
    }
  ]
}

Fallbacks and tool calling

The fallbacks array works alongside tools. If the primary model rate-limits or errors before returning a tool call, Aniron retries the same request — tools included — on the next model in the chain. See Model Fallbacks.

Build with function calling

Get an API key and start wiring up tools against any model in the catalog.