Docs

Tool calling (function calling)

Use tool calling with abliteration.ai to let models invoke external functions. OpenAI-compatible tools parameter with full examples in curl, Python, JavaScript, Java, and Go.

Updated 2026-08-04

Let models call your functions via the OpenAI-compatible tools parameter. Works with existing SDKs — just switch the base URL.

How tool calling works

Tool calling follows a multi-step loop between your application and the model.

Tool definition schema

Each tool must specify type: "function" and a function object with name, description, and parameters (JSON Schema).

{
  "type": "function",
  "function": {
    "name": "get_weather",
    "description": "Get the current weather for a given location.",
    "parameters": {
      "type": "object",
      "properties": {
        "location": {
          "type": "string",
          "description": "City and state, e.g. San Francisco, CA"
        },
        "unit": {
          "type": "string",
          "enum": ["celsius", "fahrenheit"]
        }
      },
      "required": ["location"]
    }
  }
}

Response with tool_calls

When the model invokes a tool, the response contains a tool_calls array with the function name and arguments as a JSON string.

{
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_abc123",
            "type": "function",
            "function": {
              "name": "get_order_status",
              "arguments": "{\"order_id\": \"123\"}"
            }
          }
        ]
      },
      "finish_reason": "tool_calls"
    }
  ]
}

Sending tool results back

After executing the function, append a tool-role message with the result. The tool_call_id must match the id from the original tool call.

Multiple tools

Define multiple tools in one request. The model may call one, several, or none. Execute each and return all results before the next call.

{
  "model": "abliterated-model",
  "messages": [
    { "role": "user", "content": "What's the weather in NYC and order status for 456?" }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get current weather for a location.",
        "parameters": {
          "type": "object",
          "properties": {
            "location": { "type": "string" }
          },
          "required": ["location"]
        }
      }
    },
    {
      "type": "function",
      "function": {
        "name": "get_order_status",
        "description": "Lookup an order status by id.",
        "parameters": {
          "type": "object",
          "properties": {
            "order_id": { "type": "string" }
          },
          "required": ["order_id"]
        }
      }
    }
  ]
}

Forcing a specific tool call

Use tool_choice to control invocation: "auto" (default), "none", or force a specific function.

{
  "model": "abliterated-model",
  "messages": [
    { "role": "user", "content": "Tell me about order 789." }
  ],
  "tools": [ ... ],
  "tool_choice": {
    "type": "function",
    "function": { "name": "get_order_status" }
  }
}

Best practices

Guidelines for reliable tool calling.

FAQ

Frequently asked questions.

How do I fix a 401 Unauthorized error from abliteration.ai?

Check that your API key is set and sent as a Bearer token.

How do I fix a 404 Not Found error from abliteration.ai?

Make sure the base URL ends with /v1 and you call /chat/completions.

How do I fix a 400 Bad Request error from abliteration.ai?

Verify the model id and that messages are an array of { role, content } objects.

How do I fix a 429 Rate limit error from abliteration.ai?

Back off and retry. Use the Retry-After header for pacing.