Learn how to use custom functions with Incredible API
AI excels at generating text, but real-world tasks often require actions beyond wordsβlike calling a weather API for current conditions instead of providing outdated information. Function calling allows Incredible to execute custom code and tools to take these actions.
Our agentic models perform function calling by writing code in real-time. This allows them to reference data, perform analysis, and call functions in more sophisticated ways than traditional function calling approaches.Think of functions as recipes with:
Name and description - What the function does
Parameters - Required and optional inputs
Action - What the AI can accomplish by calling it
When users make requests, the AI decides whether to respond directly or use available functions to accomplish the task.
When you define a function, youβre providing the AI with a βcookbookβ of available tools. Each function definition tells the model what it can do and what inputs it needs.
Field
Description
model
Specifies which AI model will process the request.
functions
A cookbook of tools. Each function has a name, description, and parameters.
parameters
Describes the function inputs with types, descriptions, and required fields.
messages
Represents the conversation history between user and assistant.
{ "result": { "thinking": "The user wants to calculate 25 + 17. I have an add_numbers function available.", "response": [ { "role": "assistant", "content": "I'll calculate that for you using the add_numbers function." }, { "type": "function_call", "function_call_id": "abc-123", "function_calls": [ { "name": "add_numbers", "input": {"a": 25, "b": 17} } ] } ] }}
Understanding function_call_id: This unique identifier links a function call request to its result. When you execute the function and return results, you must include the same function_call_id so the model can associate the output with the correct request. If multiple functions are called, execute them in order and return their results with the corresponding ID.
Important: The model can perform multiple types of server-side actions, and will include the results from those in the response. You must add ALL items from the response to your messages array when sending the next request, so the model can use them in subsequent steps.
{ "result": { "thinking": "The user provided the result of the addition. Now I can give them the final answer.", "response": [ { "role": "assistant", "content": "The sum of 25 and 17 is 42." } ] }}