GET
/
functions
/
{function_id}
Python
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}")
{
  "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

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 retrieve

Response

Successful Response

name
string
required

The name of the function. Must be unique within the project and can only contain letters, numbers, underscores and hyphens.

Examples:

"my-function"

"my-namespace.my-sub-function"

"my-namespace/my-sub-function"

instructions
string
required

The instructions for the function, this is the prompt that will be sent to the model to complete the task. Recommended to be concise and to the point

Examples:

"You are a calculator that adds two numbers and returns the result."

id
string<uuid>
required

The ID of the function

description
string | null

Optional description of the function. This is used to describe the function to a user.

Examples:

"This function is used to add two numbers and return the result."

input_schema
object | null

Optional input schema for the function. Can preferably include field descriptions to allow the model to reason about the input variables. Schema is validated against the input data and issues an error if it does not match. With the Opper SDKs you can define these schemas through libraries like Pydantic and Zod. For schemas with definitions, prefer using '$defs' and '#/$defs/...' references.

Examples:
{
"properties": {
"x": { "title": "X", "type": "integer" },
"y": { "title": "Y", "type": "integer" }
},
"required": ["x", "y"],
"title": "OpperInputExample",
"type": "object"
}
output_schema
object | null

Optional output schema for the function. Can preferably include field descriptions to allow the model to reason about the output variables. Schema is validated against the output data and issues an error if it does not match. With the Opper SDKs you can define these schemas through libraries like Pydantic and Zod. For schemas with definitions, prefer using '$defs' and '#/$defs/...' references.

Examples:
{
"properties": {
"sum": { "title": "Sum", "type": "integer" }
},
"required": ["sum"],
"title": "OpperOutputExample",
"type": "object"
}
model

Optionally provide a model to use for completing the task. If not provided, a default model will be used. Currently the default model is azure/gpt-4o-eu

To specify options for the model, use a dictionary of key-value pairs. The options are passed to the model on invocation. An example of passing temperature to gpt-4o-mini hosted on OpenAI is shown below.

{
"model": "openai/gpt-4o-mini", # the model name
"options": {
"temperature": 0.5 # the options for the model
}
}

To specify a fallback model, use a list of models. The models will then be tried in order. The second model will be used if the first model is not available, and so on.

[
"openai/gpt-4o-mini", # first model to try
"openai/gpt-4.1-nano", # second model to try
]
configuration
object | null

Optional configuration for the function.Configuration is a dictionary of key-value pairs that can be used to override the default configuration for the function.

Examples:
{
"beta.evaluation.enabled": true,
"invocation.cache.ttl": 0,
"invocation.few_shot.count": 0,
"invocation.structured_generation.max_attempts": 5
}
dataset_id
string<uuid> | null

The ID of the dataset associated with the function

revision_id
string<uuid> | null

The ID of the latest revision of the function