Call a function
Python
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 } }
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Bearer <token>
<token>
The id of the function to call
The id of the revision to call
Successful Response
The response is of type object.
object