Code Examples
Complete code examples for integrating the Helium Public API into your applications. Choose your preferred language or framework.
import requestsimport time class HeliumAPI: def __init__(self, api_key): self.api_key = api_key self.base_url = "https://api.he2.ai" self.headers = { "X-API-Key": api_key } def create_task(self, prompt): """Create and start a new task""" response = requests.post( f"{self.base_url}/api/v1/public/quick-action", data={"prompt": prompt}, headers=self.headers ) response.raise_for_status() return response.json() def get_results(self, thread_id, project_id, timeout=300): """Get task results""" response = requests.get( f"{self.base_url}/api/v1/public/threads/{thread_id}/response", params={"project_id": project_id, "timeout": timeout}, headers=self.headers ) response.raise_for_status() return response.json() def create_website(self, description): """Complete workflow: create and get results""" # Create task task = self.create_task(description) print(f"Task created: {task['thread_id']}") # Get results results = self.get_results(task['thread_id'], task['project_id']) if results['status'] == 'completed': print("✅ Task completed!") return results else: print(f"Status: {results['status']}") return results # Usageapi = HeliumAPI("he-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")results = api.create_website("Build a modern blog website")