Theme
Language

Function calling (tools)

How to use function calling (tool use) with GetVibe API: the tools and tool_choice parameters and a multi-turn tool conversation. Full agent loop in Python and curl.

Function calling (tool use) lets the model request calls to your functions and get the result back. Supported on all OpenAI-compatible models.

Parameters

ParameterTypeDescription
toolsarrayGPT · ClaudeList of tools. Each object: { type: "function", function: { name, description, parameters } }.
tool_choicestring | objectGPT · Claude"auto" (model decides), "none" (do not call), "required" (must call), or { type: "function", function: { name } } — a specific tool.
parallel_tool_callsbooleanGPTtrue — the model requests several tools at once. Default true. Claude does not support this flag but does parallel calls itself.

Example: single call

curl https://getvibeapi.com/v1/chat/completions \
  -H "Authorization: Bearer $GETVIBE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6.1-sol",
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Returns the current weather in a city",
        "parameters": {
          "type": "object",
          "properties": {
            "city": { "type": "string", "description": "City name" }
          },
          "required": ["city"]
        }
      }
    }],
    "tool_choice": "auto",
    "messages": [{"role": "user", "content": "What is the weather in London?"}]
  }'

Multi-turn: passing the result back

After the tool is called, add a tool role message with the result and send the next request.

# messages after the first response with tool_call:
messages = [
    {"role": "user", "content": "What is the weather in London?"},
    # model response with the tool call
    {"role": "assistant", "tool_calls": msg.tool_calls, "content": None},
    # the result of your function
    {
        "role": "tool",
        "tool_call_id": msg.tool_calls[0].id,
        "content": json.dumps({"city": "London", "temp": 18, "desc": "Cloudy"}),
    },
]
resp2 = client.chat.completions.create(model="gpt-6.1-sol", tools=tools, messages=messages)
print(resp2.choices[0].message.content)
# → "It is currently 18°C and cloudy in London."

Example response (tool_call)

{
  "choices": [{
    "message": {
      "role": "assistant",
      "content": null,
      "tool_calls": [{
        "id": "call_abc123",
        "type": "function",
        "function": {
          "name": "get_weather",
          "arguments": "{\"city\":\"London\"}"
        }
      }]
    },
    "finish_reason": "tool_calls"
  }]
}
The tools and tool_choice fields are accepted in the OpenAI-compatible form; their actual support depends on the chosen model. Do not rely on byte-for-byte pass-through or upstream-specific response fields.
GetVibe API function calling — tools, tool_choice, Python examples | GetVibe API