Skip to main content
This shows the complete two-step flow: the model returns a function call first, you execute it locally, then send back a function_call_result for the final answer.

1) Initial request (expose your functions)

curl -X POST "https://api.incredible.one/v1/chat-completion" \
-H "Content-Type: application/json" \
-d '{
  "model": "small-1",
  "messages": [{"role": "user", "content": "Calculate 25 + 17"}],
  "functions": [{
    "name": "add_numbers",
    "description": "Add two numbers together",
    "parameters": {
      "type": "object",
      "properties": {
        "a": {"type": "number", "description": "First number"},
        "b": {"type": "number", "description": "Second number"}
      },
      "required": ["a", "b"]
    }
  }]
}'
The response will include a type: "function_call" item with a function_call_id and the arguments for add_numbers.

2) Send back the function result

Execute add_numbers(a, b) locally, then include both the function call item and a function_call_result in a follow-up request:
curl -X POST "https://api.incredible.one/v1/chat-completion" \
-H "Content-Type: application/json" \
-d '{
  "model": "small-1",
  "messages": [
    {"role": "user", "content": "Calculate 25 + 17"},
    {"type": "function_call", "function_call_id": "CALL_ID_FROM_STEP_1", "function_calls": [{
      "name": "add_numbers",
      "input": {"a": 25, "b": 17}
    }]},
    {"type": "function_call_result", "function_call_id": "CALL_ID_FROM_STEP_1", "function_call_results": [42]}
  ],
  "functions": [{
    "name": "add_numbers",
    "description": "Add two numbers together",
    "parameters": {
      "type": "object",
      "properties": {
        "a": {"type": "number"},
        "b": {"type": "number"}
      },
      "required": ["a", "b"]
    }
  }]
}'
The assistant will return the final natural-language answer using the function result.
View source on GitHub → 5_function_calling.py