abliteration.ai - Uncensored LLM API Platform
Abliteration
PolicyGatewaySecurity TestingDocsMigrationGlossaryPricing
Home/Docs/Tool calling (function calling)

Docs

Tool calling (function calling)

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

Quick start

Base URL
curl https://api.abliteration.ai/v1/chat/completions \
  -H "Authorization: Bearer $ABLIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "abliterated-model",
    "messages": [
      { "role": "user", "content": "Look up the status of order 123." }
    ],
    "tools": [
      {
        "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"]
          }
        }
      }
    ]
  }'

Service notes

  • Pricing model: Usage-based pricing (~$5 per 1M tokens) billed on total tokens (input + output). See the API pricing page for current plans.
  • Data retention: No prompt/output retention by default. Operational telemetry (token counts, timestamps, error codes) is retained for billing and reliability.
  • Compatibility: OpenAI-style /v1/chat/completions request and response format with a base URL switch.
  • Latency: Depends on model size, prompt length, and load. Streaming reduces time-to-first-token.
  • Throughput: Team plans include priority throughput. Actual throughput varies with demand.
  • Rate limits: Limits vary by plan and load. Handle 429s with backoff and respect any Retry-After header.

On this page

  • How tool calling works
  • Tool definition schema
  • Response with tool_calls
  • Sending tool results back
  • Multiple tools
  • Forcing a specific tool call
  • Best practices

How tool calling works

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

  • 1. Define tools — Describe available functions with a JSON Schema in the tools array.
  • 2. Send request — The model analyzes the user message and decides whether to call a tool.
  • 3. Receive tool_calls — If the model invokes a tool, the response contains a tool_calls array instead of plain content.
  • 4. Execute function — Your code runs the function with the provided arguments.
  • 5. Return result — Send the function result back in a message with role: "tool" and the matching tool_call_id.
  • 6. Get final answer — The model incorporates the tool result and returns a natural language response.

Tool definition schema

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

Tool definition
{
  "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.

Example response
{
  "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.

curl https://api.abliteration.ai/v1/chat/completions \
  -H "Authorization: Bearer $ABLIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "abliterated-model",
    "messages": [
      { "role": "user", "content": "Look up the status of order 123." },
      {
        "role": "assistant",
        "content": null,
        "tool_calls": [{
          "id": "call_abc123",
          "type": "function",
          "function": {
            "name": "get_order_status",
            "arguments": "{\"order_id\": \"123\"}"
          }
        }]
      },
      {
        "role": "tool",
        "tool_call_id": "call_abc123",
        "content": "{\"status\": \"shipped\", \"tracking\": \"1Z999AA10\"}"
      }
    ]
  }'

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.

Multiple tools example
{
  "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.

tool_choice example
{
  "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.

  • Write clear, specific description fields so the model knows when to call each function.
  • Use required in your JSON Schema to mark mandatory parameters.
  • Always validate and parse arguments as JSON before executing the function — the model may produce malformed output in edge cases.
  • Return structured JSON in tool results so the model can interpret them consistently.
  • Keep tool result payloads concise. Large payloads consume tokens and may degrade response quality.
  • Use tool_choice: "none" when you want the model to respond without calling any tools.
  • Handle the case where tool_calls is empty or absent — the model may answer directly without invoking a tool.

Common errors & fixes

  • 400 Bad Request: Verify that each tool has type: "function" and a valid JSON Schema in parameters.
  • 400 Invalid tool_call_id: The tool_call_id in the tool-role message must match the id returned in the assistant's tool_calls.
  • 401 Unauthorized: Check that your API key is set and sent as a Bearer token.
  • 429 Rate limit: Back off and retry. Use the Retry-After header for pacing.

Related links

  • OpenAI compatibility guide
  • Streaming chat completions
  • Python SDK quickstart
  • Node.js SDK quickstart
  • See API Pricing
  • View Uncensored Models
  • Rate limits
  • Privacy policy
ProductDocumentationRun in PostmanGlossary
Trust & LegalData Handling FAQTrust CenterPrivacy PolicyTerms of Service
ConnectHugging Facehelp@abliteration.ai
FacebookX (Twitter)LinkedIn

© 2025 Social Keyboard, Inc. All rights reserved.