import requests
import json
BASE_URL = "https://orch.zenbase.ai/api"
API_KEY = "YOUR ZENBASE API KEY"
def api_call(method, endpoint, data=None):
url = f"{BASE_URL}/{endpoint}"
headers = {
"Content-Type": "application/json",
"Authorization": f"Api-Key {API_KEY}"
}
response = requests.request(method, url, headers=headers, data=json.dumps(data) if data else None)
return response
function_data = {
"name": "Sentiment Analysis",
"description": "Analyze the sentiment of a given text.",
"input_schema": {
"properties": {"text": {"title": "Text", "type": "string"}},
"required": ["text"],
"title": "SentimentInput",
"type": "object",
},
"output_schema": {
"properties": {
"sentiment": {"enum": ["positive", "negative", "neutral"], "title": "Sentiment", "type": "string"}
},
"required": ["sentiment"],
"title": "SentimentOutput",
"type": "object",
},
"prompt": """Analyze the sentiment of the given text.
Determine if the sentiment is positive, negative, or neutral.""",
"api_key": "MODEL API KEY",
"model": "MODEL NAME", # for example gpt-4o-mini
"base_url": "", # Optional: URL for custom LiteLLM server
}
function = api_call("POST", "functions/", function_data)
function_id = function.json()['id']