import requests
# Step 1: Upload the file
with open("sales_data.csv", "rb") as f:
upload_response = requests.post(
"https://api.zarkai.xyz/v1/storage/files",
headers={"x-api-key": "your_api_key"},
files={"file": ("sales_data.csv", f, "text/csv")},
)
file_id = upload_response.json()["fileId"]
# Step 2: Query it
response = requests.post(
"https://api.zarkai.xyz/v1/chat",
headers={
"x-api-key": "your_api_key",
"Content-Type": "application/json",
},
json={
"messages": [
{"role": "user", "content": "What's the total revenue by product category?"}
],
"workspace_id": "wks-xxxxx",
"file_ids": [file_id],
"tools": ["database"],
"tool_choice": "auto",
},
)
print(response.json()["response"])