API Reference
Platform APIs
- Models
- Functions
- Observability
- Knowledge base
- Datasets
- Other
Functions
Get Function
Get the latest revision of a function by ID
GET
/
functions
/
{function_id}
Copy
Ask AI
from opperai import Opper
import time
opper = Opper(http_bearer="YOUR_API_KEY")
# First, create a function to have a real ID to work with
unique_name = f"country_capital_expert_{int(time.time())}"
created_function = opper.functions.create(
name=unique_name,
description="Expert that knows about countries and their capitals",
instructions="You are a geography expert. When given a country name, respond with its capital city.",
model="openai/gpt-4o-mini",
)
print(f"Created function with ID: {created_function.id}")
# Now get the function by its ID
function = opper.functions.get(function_id=created_function.id)
print(f"Function: {function.name}")
print(f"Description: {function.description}")
print(f"Instructions: {function.instructions}")
print(f"Model: {function.model}")
print(f"Dataset ID: {function.dataset_id}")
print(f"Revision ID: {function.revision_id}")
# Print schemas if they exist
if function.input_schema:
print(f"Input schema: {function.input_schema}")
if function.output_schema:
print(f"Output schema: {function.output_schema}")
Copy
Ask AI
{
"name": "my-function",
"description": "This function is used to add two numbers and return the result.",
"instructions": "You are a calculator that adds two numbers and returns the result.",
"input_schema": {
"properties": {
"x": {
"title": "X",
"type": "integer"
},
"y": {
"title": "Y",
"type": "integer"
}
},
"required": [
"x",
"y"
],
"title": "OpperInputExample",
"type": "object"
},
"output_schema": {
"properties": {
"sum": {
"title": "Sum",
"type": "integer"
}
},
"required": [
"sum"
],
"title": "OpperOutputExample",
"type": "object"
},
"model": {
"extra_headers": {},
"name": "openai/gpt-4o-mini",
"options": {
"temperature": 0.5
}
},
"configuration": {
"beta.evaluation.enabled": true,
"invocation.cache.ttl": 0,
"invocation.few_shot.count": 0,
"invocation.structured_generation.max_attempts": 5
},
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dataset_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"revision_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Path Parameters
The id of the function to retrieve
Response
200
application/json
Successful Response
The response is of type object
.
Copy
Ask AI
from opperai import Opper
import time
opper = Opper(http_bearer="YOUR_API_KEY")
# First, create a function to have a real ID to work with
unique_name = f"country_capital_expert_{int(time.time())}"
created_function = opper.functions.create(
name=unique_name,
description="Expert that knows about countries and their capitals",
instructions="You are a geography expert. When given a country name, respond with its capital city.",
model="openai/gpt-4o-mini",
)
print(f"Created function with ID: {created_function.id}")
# Now get the function by its ID
function = opper.functions.get(function_id=created_function.id)
print(f"Function: {function.name}")
print(f"Description: {function.description}")
print(f"Instructions: {function.instructions}")
print(f"Model: {function.model}")
print(f"Dataset ID: {function.dataset_id}")
print(f"Revision ID: {function.revision_id}")
# Print schemas if they exist
if function.input_schema:
print(f"Input schema: {function.input_schema}")
if function.output_schema:
print(f"Output schema: {function.output_schema}")
Copy
Ask AI
{
"name": "my-function",
"description": "This function is used to add two numbers and return the result.",
"instructions": "You are a calculator that adds two numbers and returns the result.",
"input_schema": {
"properties": {
"x": {
"title": "X",
"type": "integer"
},
"y": {
"title": "Y",
"type": "integer"
}
},
"required": [
"x",
"y"
],
"title": "OpperInputExample",
"type": "object"
},
"output_schema": {
"properties": {
"sum": {
"title": "Sum",
"type": "integer"
}
},
"required": [
"sum"
],
"title": "OpperOutputExample",
"type": "object"
},
"model": {
"extra_headers": {},
"name": "openai/gpt-4o-mini",
"options": {
"temperature": 0.5
}
},
"configuration": {
"beta.evaluation.enabled": true,
"invocation.cache.ttl": 0,
"invocation.few_shot.count": 0,
"invocation.structured_generation.max_attempts": 5
},
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dataset_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"revision_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
Assistant
Responses are generated using AI and may contain mistakes.