The xpander.ai Client API provides a comprehensive interface for interacting with the xpander.ai platform. This documentation covers the core API methods, request/response formats, and authentication mechanisms.
# Stream operation resultsfor chunk in client.stream_operation("operation-id", input={"query": "Tell me a story"}): print(chunk.content, end="", flush=True)
The API uses standard HTTP status codes to indicate success or failure:
200: Success
400: Bad request (invalid parameters)
401: Unauthorized (invalid API key)
404: Resource not found
429: Rate limit exceeded
500: Server error
Copy
Ask AI
try: result = client.execute_operation("operation-id", input={"query": "Hello"})except xpander_sdk.APIError as e: if e.status_code == 401: print("Authentication error. Check your API key.") elif e.status_code == 404: print("Operation not found.") else: print(f"API error: {e}")