POST
/
call
from typing import Optional

from opperai import Opper
from pydantic import BaseModel, Field

opper = Opper(http_bearer="YOUR_API_KEY")


class CountryInput(BaseModel):
    country: str = Field(description="The name of the country")


class CapitalOutput(BaseModel):
    capital: str = Field(description="The capital city of the country")
    population: Optional[int] = Field(
        None, description="The population of the capital city"
    )


input_data = CountryInput(country="Sweden")

response = opper.call(
    name="get_capital",
    instructions="What is the capital of the provided country? Also include the population if you know it.",
    input_schema=CountryInput,
    output_schema=CapitalOutput,
    input=input_data,
)

print(response)
{
  "span_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "message": "The sum of 1 and 3 is 4",
  "json_payload": {
    "sum": 4
  },
  "audio": {},
  "cached": true,
  "images": [
    "image_url"
  ]
}

Authorizations

Authorization
string
header
required

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

Body

application/json

Response

200
application/json

Successful Response

The response is of type object.