Log in at platform.opper.ai and create your own API key
in the top right menu. Each api key is associated with a project, you will have all calls, functions,
indexes and traces associated with this project. There is a default project for each organization
but it is recommended to create a new project to better being able to separate the different applications
and environments.
Install our SDK for your preferred language. There are currently SDKs available for Python and TypeScript.
If your language is not supported, you can use the REST API directly. See the API reference
for more information.
Let’s write a simple call that extracts room descriptions from text as structured output.
Copy
Ask AI
from opperai import Opper# Our SDK supports Pydantic to provide structured outputfrom pydantic import BaseModelimport os# Define the output structureclass RoomDescription(BaseModel): room_count: int view: str bed_size: str hotel_name: strdef main(): opper = Opper(http_bearer=os.getenv("OPPER_API_KEY")) # Complete a task completion = opper.call( name="extractRoom", instructions="Extract details about the room from the provided text", input="The Grand Hotel offers a luxurious suite with 3 spacious rooms, each providing a breathtaking view of the ocean. The suite includes a king-sized bed, an en-suite bathroom, and a private balcony for an unforgettable stay.", output_schema=RoomDescription, ) print(completion.json_payload) #{'room_count': 3, 'view': 'ocean', 'bed_size': 'king-sized', 'hotel_name': 'The Grand Hotel'}main()