Tool Calling

Tool calling allows you to connect models like GPT-4o and Claude 3.5 to external tools and APIs.

Defining Tools

JSON Schema
const tools = [
  {
    "type": "function",
    "function": {
      "name": "get_weather",
      "description": "Get the current weather in a given location",
      "parameters": {
        "type": "object",
        "properties": {
          "location": { "type": "string" },
          "unit": { "type": "string", "enum": ["celsius", "fahrenheit"] }
        },
        "required": ["location"]
      }
    }
  }
];

The Request

cURL Request
curl https://api.qorebit.ai/v1/chat/completions \
  -H "Authorization: Bearer qb_live_..." \
  -d '{
    "model": "openai/gpt-4o",
    "messages": [{"role": "user", "content": "What is the weather in London?"}],
    "tools": [...],
    "tool_choice": "auto"
  }'