Skip to content

Function calling

Describe your functions; the model decides when to call them, your code executes them and returns the result.

Updated on Aug 10, 2026

In function calling, you describe functions to the assistant and it intelligently returns which ones to call and with which arguments — your code executes them. The run pauses at requires_action, waits for results, and continues with them.

Step 1: describe the functions

Functions go into tools when creating the assistant, with parameters in JSON Schema:

curl -s https://api.hinow.ai/v1/assistants \
  -H "Authorization: Bearer hi_SUA_API_KEY" -H "Content-Type: application/json" \
  -d '{
    "model": "hinow/himax",
    "name": "Meteorologista",
    "instructions": "Use get_weather para responder sobre o clima.",
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Obtém o clima atual de uma cidade",
        "parameters": {
          "type": "object",
          "properties": {"city": {"type": "string", "description": "Nome da cidade"}},
          "required": ["city"]
        }
      }
    }]
  }'

Step 2: run and observe requires_action

When the question triggers a function, the run pauses at requires_action. The object brings the pending calls — each with id, name, and arguments the model chose:

{
  "id": "run_e31d5fe7...",
  "status": "requires_action",
  "required_action": {
    "type": "submit_tool_outputs",
    "submit_tool_outputs": {
      "tool_calls": [{
        "id": "call_00_R8JQ...",
        "type": "function",
        "function": {"name": "get_weather", "arguments": "{\"city\": \"Curitiba\"}"}
      }]
    }
  }
}

Step 3: execute and return the results

POSThttps://api.hinow.ai/v1/threads/{thread_id}/runs/{run_id}/submit_tool_outputsBearer

Submit the function results; the run continues from where it stopped.

Parâmetros

  • thread_idstring· pathobrigatório
  • run_idstring· pathobrigatório
  • tool_outputsarray· bodyobrigatório

    [{"tool_call_id": "call_...", "output": "..."}] — all pending calls, in a single request.

  • streamboolean· body

    true continues the run in SSE, with the same events.

Respostas

200The resumed run (queued → final response)
400Unknown tool_call_id, missing, or run not in requires_action
curl -s https://api.hinow.ai/v1/threads/$THREAD/runs/$RUN/submit_tool_outputs \
  -H "Authorization: Bearer hi_SUA_API_KEY" -H "Content-Type: application/json" \
  -d '{
    "tool_outputs": [{
      "tool_call_id": "call_00_R8JQ...",
      "output": "{\"temperatura\": \"14°C\", \"condicao\": \"chuvisco\"}"
    }]
  }'

The run returns to queued, the model reads the results and writes the final response to the thread. Run steps record everything: the tool_calls step stores arguments and the output you submitted; the message_creation closes the loop.

All at once, within the deadline

Submit outputs for all pending tool_calls in a single request — partial submissions are rejected with 400 and the list of expected ids. And within the run window: 10 minutes after creation, a run in requires_action expires.

The model can call multiple functions at once (parallel_tool_calls, enabled by default) — the tool_calls array brings all of them, and you return all together. With stream: true in submit, the continuation arrives via SSE like any run.

Was this page helpful?