POST
/
functions
/
{function_id}
/
call
/
{revision_id}
Call Function Revision
import requests

url = "https://api.opper.ai/v2/functions/{function_id}/call/{revision_id}"

payload = {
    "input": "<any>",
    "parent_span_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "examples": [
        {
            "comment": "Adds two numbers",
            "input": {
                "x": 1,
                "y": 3
            },
            "output": { "sum": 4 }
        }
    ],
    "tags": { "tag": "value" }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
{
  "span_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "message": "The sum of 1 and 3 is 4",
  "json_payload": "<any>",
  "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
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

function_id
string<uuid>
required

The id of the function to call

revision_id
string<uuid>
required

The id of the revision to call

Body

application/json
input
any

Input to the function

parent_span_id
string<uuid> | null
examples
ExampleIn · object[] | null
Examples:
[
{
"comment": "Adds two numbers",
"input": { "x": 1, "y": 3 },
"output": { "sum": 4 }
}
]
tags
object | null

Tags to add to the call event

Examples:
{ "tag": "value" }

Response

Successful Response

span_id
string<uuid>
required

The ID of the span of the call

message
string | null

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

Examples:

"The sum of 1 and 3 is 4"

json_payload
any

Result of the task if the call uses an output schema

cached
boolean
default:false

True if the result was returned from a cached results

Examples:

true

images
string[] | null

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.

Examples:
["image_url"]
usage
object | null

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.

Examples:
{
"input_tokens": 25,
"output_tokens": 972,
"output_tokens_details": { "reasoning_tokens": 704 },
"total_tokens": 997
}
cost
object | null

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

Examples:
{
"generation": 0.0001,
"platform": 0.00001,
"total": 0.00011
}