v2

latestOpenAPI 3.1.02026-07-2670186350.6 KB
functions

Create Function

Create a function

post/functions

Request body

namestring required

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

descriptionstring nullable

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

instructionsstring 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

input_schemaobject nullable

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.

output_schemaobject nullable

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.

Example request

{
  "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"
  }
}

Response

Successful Response

namestring required

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

descriptionstring nullable

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

instructionsstring 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

input_schemaobject nullable

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.

output_schemaobject nullable

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.

idstring uuid required

The ID of the function

dataset_idstring uuid nullable

The ID of the dataset associated with the function

revision_idstring uuid nullable

The ID of the latest revision of the function

observer_enabledboolean

Whether the observer is enabled for this function. When enabled, the observer monitors and evaluates all generations.

is_v3boolean

Whether this function has been executed through the v3 API

Example response

{
  "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"
  }
}