v2

latestOpenAPI 3.1.02026-07-2670186350.6 KB
functions

Call Function

Call a function

post/functions/{function_id}/call

Path parameters

function_idstring uuid required

The id of the function to call

The id of the function to call

Request body

{"stackTrail":"components:schemas:app__api__public__v2__functions__CallFunctionRequest:properties:input:anyOf","oasType":"schema","type":"unknown","title":"Input","description":"Input to the function","example":{"x":4,"y":5},"nullable":true}
parent_span_idstring uuid nullable
tagsobject nullable

Tags to add to the call event

Example request

{
  "input": {
    "x": 4,
    "y": 5
  },
  "examples": [
    {
      "comment": "Adds two numbers",
      "input": {
        "x": 1,
        "y": 3
      },
      "output": {
        "sum": 4
      }
    }
  ],
  "tags": {
    "tag": "value"
  }
}

Response

Successful Response

span_idstring uuid required

The ID of the span of the call

messagestring nullable

Result of the task if the call does not use an output schema

{"stackTrail":"components:schemas:app__api__public__v2__functions__CallFunctionResponse:properties:json_payload:anyOf","oasType":"schema","type":"unknown","title":"Json Payload","description":"Result of the task if the call uses an output schema","example":{"sum":4},"nullable":true}
cachedboolean

True if the result was returned from a cached results

imagesstring[] nullable

The images generated by the call. Only available for image models. Depending on the configuration, the response can either be a list of image urls or a base64 encoded images.

usageobject nullable

The usage of the call split into input and output tokens as well as the total tokens and an optional breakdown of the input and output tokens.The input tokens are the tokens sent to the model and the output tokens are the tokens received from the model. The total tokens is the sum of input and output tokens.

costobject nullable

The cost in USD of the call split into total, generation and platform costs where total is the sum of generation and platform costs

Example response

{
  "message": "The sum of 1 and 3 is 4",
  "json_payload": {
    "sum": 4
  },
  "cached": true,
  "images": [
    "image_url"
  ],
  "usage": {
    "input_tokens": 25,
    "output_tokens": 972,
    "output_tokens_details": {
      "reasoning_tokens": 704
    },
    "total_tokens": 997
  },
  "cost": {
    "generation": 0.0001,
    "platform": 0.00001,
    "total": 0.00011
  }
}