### Install OpenAI SDK Source: https://docs.eachlabs.ai/sdks/javascript Install the required dependency to interact with the OpenAI-compatible API. ```bash npm install openai ``` -------------------------------- ### Install OpenAI SDK Source: https://docs.eachlabs.ai/sense/quickstart Install the necessary OpenAI SDK for your project using pip for Python or npm for JavaScript. ```bash pip install openai ``` ```bash npm install openai ``` -------------------------------- ### Chat Completions Integration Examples Source: https://docs.eachlabs.ai/sense/endpoints/chat-completions Examples showing how to interact with the chat completions API using cURL, Python, and JavaScript. ```bash curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "messages": [{"role": "user", "content": "Generate a sunset over mountains"}], "stream": true, "session_id": "my-session", "mode": "max" }' ``` ```python from openai import OpenAI client = OpenAI( api_key="YOUR_API_KEY", base_url="https://eachsense-agent.core.eachlabs.run/v1" ) response = client.chat.completions.create( model="eachsense/beta", messages=[{"role": "user", "content": "Generate a sunset over mountains"}], stream=False ) print(response.choices[0].message.content) ``` ```javascript import OpenAI from "openai"; const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://eachsense-agent.core.eachlabs.run/v1", }); const response = await client.chat.completions.create({ model: "eachsense/beta", messages: [{ role: "user", content: "Generate a sunset over mountains" }], stream: false, }); console.log(response.choices[0].message.content); ``` -------------------------------- ### Install OpenAI Python SDK Source: https://docs.eachlabs.ai/sdks/python Install the necessary Python package for interacting with OpenAI-compatible APIs. ```bash pip install openai ``` -------------------------------- ### 404 Not Found Error Example Source: https://docs.eachlabs.ai/errors Returned when the requested resource does not exist. ```json { "error": "Failed to fetch model: model not found" } ``` -------------------------------- ### Configure a Model Step Source: https://docs.eachlabs.ai/workflows/concepts/workflow-structure Example of a step configured to invoke an AI model. ```json { "id": "generate_image", "type": "model", "model": "flux-1-1-pro", "params": { "prompt": "{{inputs.prompt}}", "aspect_ratio": "16:9" } } ``` -------------------------------- ### Streaming SSE Events with EachLabs Extension Source: https://docs.eachlabs.ai/llms.txt Example of Server-Sent Events (SSE) with OpenAI chat.completion.chunk format and an EachLabs extension for generation responses. Includes example data for an image generation. ```text data: {"id":"chatcmpl-123","object":"chat.completion.chunk","choices":[{"delta":{"content":""}}],"eachlabs":{"type":"generation_response","url":"https://cdn.example.com/image.png","generations":["..."],"model":"flux-2-max","execution_time_ms":8500}} data: [DONE] ``` -------------------------------- ### GET /v1/webhooks Source: https://docs.eachlabs.ai/api/overview List all configured webhooks. ```APIDOC ## GET /v1/webhooks ### Description List all webhooks associated with your account. ### Method GET ### Endpoint /v1/webhooks ``` -------------------------------- ### Fetch Workflow Details Source: https://docs.eachlabs.ai/workflows/endpoints/get-workflow Examples for retrieving workflow information using an API key for authentication. ```bash curl https://workflows.eachlabs.run/api/v1/workflows/50741f40-8621-4d46-8a91-dff4d873be98 \ -H "X-API-Key: YOUR_API_KEY" ``` ```python import requests response = requests.get( "https://workflows.eachlabs.run/api/v1/workflows/text-to-image-generator", headers={"X-API-Key": "YOUR_API_KEY"} ) workflow = response.json() print(f"{workflow['name']} | v{workflow['latest_version_id']}") ``` ```javascript const response = await fetch( "https://workflows.eachlabs.run/api/v1/workflows/text-to-image-generator", { headers: { "X-API-Key": "YOUR_API_KEY" } } ); const workflow = await response.json(); console.log(`${workflow.name} | v${workflow.latest_version_id}`); ``` -------------------------------- ### List Webhooks Implementation Source: https://docs.eachlabs.ai/api/webhooks/list-webhooks Examples for fetching a list of webhooks using cURL, Python, and JavaScript. ```bash curl "https://api.eachlabs.ai/v1/webhooks?limit=10" \ -H "X-API-Key: YOUR_API_KEY" ``` ```python import requests response = requests.get( "https://api.eachlabs.ai/v1/webhooks", params={"limit": 10}, headers={"X-API-Key": "YOUR_API_KEY"} ) data = response.json() for webhook in data["webhooks"]: print(f"{webhook['execution_id']} → {webhook['url']}") ``` ```javascript const response = await fetch( "https://api.eachlabs.ai/v1/webhooks?limit=10", { headers: { "X-API-Key": "YOUR_API_KEY" } } ); const data = await response.json(); data.webhooks.forEach((wh) => { console.log(`${wh.execution_id} → ${wh.url}`); }); ``` -------------------------------- ### Tool chaining examples Source: https://docs.eachlabs.ai/sense/tools Common patterns for chaining multiple tools to achieve complex workflows. ```text 1. search_models("portrait generation") → finds nano-banana-pro 2. get_model_details("nano-banana-pro") → gets input schema 3. execute_model("nano-banana-pro", {...}) → generates image [TERMINAL] ``` ```text 1. vision_preprocessor([image_url]) → analyzes image 2. search_models("remove background") → finds model 3. execute_model("eachlabs-bg-remover-v1") → removes bg [TERMINAL] ``` ```text 1. search_models("portrait generation") → finds models 2. search_models("image to video") → finds more models 3. create_workflow({...}) → creates workflow 4. trigger_workflow(...) → starts execution 5. check_execution(...) → monitors progress [TERMINAL] ``` -------------------------------- ### Streaming Response Example Source: https://docs.eachlabs.ai/sense/endpoints/chat-completions This example shows the Server-Sent Events (SSE) format for streaming responses, including content chunks and completion signals. Ensure your client is configured to handle SSE. ```text data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","model":"eachsense/beta","choices":[{"index":0,"delta":{"content":"I'll generate..."},"finish_reason":null}],"eachlabs":{"type":"text_response"}} data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","model":"eachsense/beta","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"eachlabs":{"type":"generation_response","url":"https://..."}} data: [DONE] ``` -------------------------------- ### List models with filters Source: https://docs.eachlabs.ai/api/models/list-models Examples of how to query the models endpoint with name filtering and pagination parameters. ```bash curl "https://api.eachlabs.ai/v1/models?name=flux&limit=10" ``` ```python import requests response = requests.get( "https://api.eachlabs.ai/v1/models", params={"name": "flux", "limit": 10} ) models = response.json() for model in models: print(f"{model['slug']} | {model['title']}") ``` ```javascript const response = await fetch( "https://api.eachlabs.ai/v1/models?name=flux&limit=10" ); const models = await response.json(); models.forEach((model) => { console.log(`${model.slug} | ${model.title}`); }); ``` -------------------------------- ### Interact with each::sense using OpenAI SDK Source: https://docs.eachlabs.ai/llms.txt Examples for non-streaming, streaming, eco-mode, and multi-turn interactions with the eachsense/beta model. ```python from openai import OpenAI client = OpenAI( api_key="YOUR_API_KEY", base_url="https://eachsense-agent.core.eachlabs.run/v1" ) # Non-streaming response = client.chat.completions.create( model="eachsense/beta", messages=[{"role": "user", "content": "Generate a sunset landscape"}], stream=False ) print(response.generations) # Streaming stream = client.chat.completions.create( model="eachsense/beta", messages=[{"role": "user", "content": "Generate a sunset landscape"}], stream=True ) for chunk in stream: eachlabs_data = chunk.model_extra.get("eachlabs") if eachlabs_data: event_type = eachlabs_data.get("type") if event_type == "generation_response": print(eachlabs_data["generations"]) # Eco mode response = client.chat.completions.create( model="eachsense/beta", messages=[{"role": "user", "content": "Generate a quick sketch"}], extra_body={"mode": "eco"}, stream=False ) # Multi-turn with session response = client.chat.completions.create( model="eachsense/beta", messages=[{"role": "user", "content": "Now make it wider"}], extra_body={"session_id": "my-session"}, stream=False ) ``` -------------------------------- ### Fetch Model Information (Python) Source: https://docs.eachlabs.ai/api/models/get-model This Python script uses the requests library to get AI model details. Ensure you have the library installed and replace 'YOUR_API_KEY' with your actual key. ```python import requests response = requests.get( "https://api.eachlabs.ai/v1/model", params={"slug": "flux-1-1-pro"}, headers={"X-API-Key": "YOUR_API_KEY"} ) model = response.json() print(f"Model: {model['title']}") print(f"Input schema: {model['request_schema']}") ``` -------------------------------- ### Getting Your API Key Source: https://docs.eachlabs.ai/authentication Instructions on how to obtain an API key from the eachlabs.ai dashboard. ```APIDOC ## Getting Your API Key 1. Sign in to [eachlabs.ai](https://eachlabs.ai) 2. Navigate to **Settings** > **API Keys** 3. Click **Create API Key** 4. Copy and store your key securely Your API key grants full access to your account. Never expose it in client-side code, public repositories, or logs. ``` -------------------------------- ### each::sense (OpenAI SDK) Source: https://docs.eachlabs.ai/llms.txt This section demonstrates how to use the EachLabs OpenAI-compatible SDK for making requests. It includes examples for both non-streaming and streaming responses. ```APIDOC ## each::sense (OpenAI SDK) ### Description Use the EachLabs OpenAI-compatible SDK to interact with the `eachsense/beta` model. This SDK simplifies making API calls for tasks like image generation. ### Installation ```bash npm install openai ``` ### Usage ```javascript import OpenAI from "openai"; const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://eachsense-agent.core.eachlabs.run/v1" }); // Non-streaming example const response = await client.chat.completions.create({ model: "eachsense/beta", messages: [{ role: "user", content: "Generate a sunset landscape" }], stream: false }); console.log(response.generations); // Streaming example const stream = await client.chat.completions.create({ model: "eachsense/beta", messages: [{ role: "user", content: "Generate a sunset landscape" }], stream: true }); for await (const chunk of stream) { const eachlabs = chunk.eachlabs; if (eachlabs?.type === "generation_response") { console.log(eachlabs.generations); } } ``` ### Parameters - **apiKey** (string): Your unique EachLabs API key. - **baseURL** (string): The base URL for the EachLabs API endpoint. - **model** (string): The model to use for generation (e.g., `eachsense/beta`). - **messages** (array): An array of message objects, typically with `role` and `content`. - **stream** (boolean): Whether to stream the response. Defaults to `false`. ``` -------------------------------- ### List Models via Python Source: https://docs.eachlabs.ai/sense/endpoints/models Use the OpenAI Python client to list models. Ensure you have the `openai` library installed and replace YOUR_API_KEY and the base URL if necessary. ```python from openai import OpenAI client = OpenAI( api_key="YOUR_API_KEY", base_url="https://eachsense-agent.core.eachlabs.run/v1" ) models = client.models.list() for model in models.data: print(f"{model.id} | owned by {model.owned_by}") ``` -------------------------------- ### Fetch Categories Implementation Source: https://docs.eachlabs.ai/workflows/endpoints/categories Examples for authenticating and retrieving category data using cURL, Python, and JavaScript. ```bash curl https://workflows.eachlabs.run/api/v1/categories \ -H "X-API-Key: YOUR_API_KEY" ``` ```python import requests response = requests.get( "https://workflows.eachlabs.run/api/v1/categories", headers={"X-API-Key": "YOUR_API_KEY"} ) for cat in response.json()["categories"]: print(f"{cat['slug']}: {cat['label']}") ``` ```javascript const response = await fetch( "https://workflows.eachlabs.run/api/v1/categories", { headers: { "X-API-Key": "YOUR_API_KEY" } } ); const { categories } = await response.json(); categories.forEach((c) => console.log(`${c.slug}: ${c.label}`)); ``` -------------------------------- ### GET /v1/models Source: https://docs.eachlabs.ai/api/overview Retrieve a list of all available AI models. ```APIDOC ## GET /v1/models ### Description List all available AI models accessible through the platform. ### Method GET ### Endpoint /v1/models ``` -------------------------------- ### Choice Step with Simple Condition Source: https://docs.eachlabs.ai/llms.txt Route execution based on a condition. This example uses a simple string match operator to determine which branch to execute. ```json { "id": "step2", "type": "choice", "condition": { "expression": "$.step1.primary", "operator": "string_matches", "value": ".mp4" }, "condition_met_branch": { "name": "condition_met", "step_id": "step2_condition_met", "steps": [ {"id": "step2_branch_0", "type": "model", "model": "topaz-upscale-video", "params": {"video": "{{step1.primary}}", "scale": 2}} ] }, "default_branch": { "name": "default", "step_id": "step2_default", "steps": [ {"id": "step2_default", "type": "model", "model": "topaz-upscale-image", "params": {"image_url": "{{step1.primary}}", "scale": 2}} ] } } ``` -------------------------------- ### Fetch Model Information (JavaScript) Source: https://docs.eachlabs.ai/api/models/get-model This JavaScript example demonstrates fetching AI model data using the fetch API. It requires an API key for authentication. ```javascript const response = await fetch( "https://api.eachlabs.ai/v1/model?slug=flux-1-1-pro", { headers: { "X-API-Key": "YOUR_API_KEY" }, } ); const model = await response.json(); console.log(`Model: ${model.title}`); ``` -------------------------------- ### HTTP Step Configuration Source: https://docs.eachlabs.ai/llms.txt Example configuration for an HTTP step within a workflow, including URL, method, headers, body, and authentication. ```APIDOC ### HTTP Steps ```json { "id": "call_api", "type": "http", "url": "https://api.example.com/process", "method": "POST", "headers": {"Content-Type": "application/json"}, "body": {"data": "{{step1.primary}}"}, "auth": {"type": "bearer", "token": "{{inputs.api_token}}"}, "timeout": 30000 } ``` **Auth types**: `basic` (username/password), `bearer` (token), `api_key`. ``` -------------------------------- ### Generate Image with each::sense (Python OpenAI SDK) Source: https://docs.eachlabs.ai/llms.txt This Python snippet demonstrates how to generate media using the each::sense AI agent via the OpenAI SDK. Ensure you have the 'openai' library installed and configure the API key and base URL. ```python from openai import OpenAI client = OpenAI( api_key="YOUR_API_KEY", base_url="https://eachsense-agent.core.eachlabs.run/v1" ) response = client.chat.completions.create( model="eachsense/beta", messages=[{"role": "user", "content": "Generate a cinematic sunset landscape in 16:9"}], stream=False ) print(response.generations) # List of media URLs ``` -------------------------------- ### List Models via JavaScript Source: https://docs.eachlabs.ai/sense/endpoints/models Use the OpenAI JavaScript client to list models. Ensure you have the `openai` library installed and replace YOUR_API_KEY and the base URL if necessary. ```javascript import OpenAI from "openai"; const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://eachsense-agent.core.eachlabs.run/v1", }); const models = await client.models.list(); models.data.forEach((m) => console.log(`${m.id} | ${m.owned_by}`)); ``` -------------------------------- ### Perform Chat Completions Source: https://docs.eachlabs.ai/sense/overview Examples for generating content using the OpenAI SDK or direct cURL requests. ```python from openai import OpenAI client = OpenAI( api_key="YOUR_EACHLABS_API_KEY", base_url="https://eachsense-agent.core.eachlabs.run/v1" ) response = client.chat.completions.create( model="eachsense/beta", messages=[{"role": "user", "content": "Generate a portrait photo"}], stream=True ) for chunk in response: if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="") ``` ```bash curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "messages": [{"role": "user", "content": "Generate a portrait photo"}], "stream": false }' ``` -------------------------------- ### Create Workflow via Natural Language with Python Source: https://docs.eachlabs.ai/sense/examples Create a workflow by describing it in natural language. This example demonstrates creating a workflow for image generation and animation. ```python import requests import json URL = "https://eachsense-agent.core.eachlabs.run/v1/chat/completions" HEADERS = {"Content-Type": "application/json", "X-API-Key": "YOUR_API_KEY"} # Create workflow response = requests.post(URL, headers=HEADERS, json={ "messages": [{ "role": "user", "content": "Create a workflow: 1) Generate portrait from description, 2) Animate into 5s video" }], "stream": True }, stream=True) for line in response.iter_lines(): if not line: continue line = line.decode("utf-8") if line.startswith("data: ") and line[6:] != "[DONE]": event = json.loads(line[6:]) if event["type"] == "workflow_created": print(f"Workflow created: {event['workflow_id']}") elif event["type"] == "text_response": print(event["content"]) ``` -------------------------------- ### Python Step Configuration Source: https://docs.eachlabs.ai/llms.txt Example configuration for a Python step within a workflow, allowing custom code execution. ```APIDOC ### Python Steps ```json { "id": "transform", "type": "python", "code": "result = inputs['text'].upper()", "inputs": {"text": "{{step1.primary}}"} } ``` ``` -------------------------------- ### Workflow Creation Events Source: https://docs.eachlabs.ai/sense/workflows These are example events emitted by the agent during workflow creation, indicating status updates and the final creation confirmation. ```text data: {"type":"status","message":"Creating workflow..."} data: {"type":"workflow_created","workflow_id":"wf_abc123","version_id":"v1","steps_count":3} data: {"type":"text_response","content":"I've created your workflow!"} data: {"type":"complete","status":"ok"} data: [DONE] ``` -------------------------------- ### Python SSE Chat Stream with OpenAI SDK Source: https://docs.eachlabs.ai/sense/streaming/implementation Utilize the OpenAI SDK in Python to stream chat completions. This example shows how to configure the client with a custom base URL and API key, and how to access both standard content and custom 'eachlabs' extensions from the stream chunks. ```python from openai import OpenAI client = OpenAI( api_key="YOUR_API_KEY", base_url="https://eachsense-agent.core.eachlabs.run/v1" ) stream = client.chat.completions.create( model="eachsense/beta", messages=[{"role": "user", "content": "Generate a portrait"}], stream=True ) for chunk in stream: if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="", flush=True) # Access each::labs extensions if hasattr(chunk, "model_extra") and chunk.model_extra: eachlabs = chunk.model_extra.get("eachlabs", {}) if eachlabs.get("type") == "generation_response": print(f"\nGenerated: {eachlabs.get('url')}") ``` -------------------------------- ### Get Session Memory Response Source: https://docs.eachlabs.ai/sense/endpoints/sessions-memory Example JSON response containing conversation history and total exchange count. ```json { "session_id": "my-session", "conversation_history": [ { "timestamp": "2024-01-15T10:30:00Z", "user_prompt": "Generate a portrait", "chatbot_response": "Here's your portrait!", "generated_media_urls": ["https://storage.eachlabs.ai/xxx.png"] } ], "total_exchanges": 1, "generated_media_urls": ["https://storage.eachlabs.ai/xxx.png"] } ``` -------------------------------- ### Initialize OpenAI Client Source: https://docs.eachlabs.ai/sdks/javascript Configure the OpenAI client to point to the each::sense base URL. ```javascript import OpenAI from "openai"; const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://eachsense-agent.core.eachlabs.run/v1", }); ``` -------------------------------- ### Initialize OpenAI-compatible client Source: https://docs.eachlabs.ai/llm-router/quickstart Configure the client to point to the each::labs base URL using your API key. ```python from openai import OpenAI client = OpenAI( api_key="YOUR_EACHLABS_API_KEY", base_url="https://api.eachlabs.ai/v1" ) ``` ```typescript import OpenAI from "openai"; const client = new OpenAI({ apiKey: "YOUR_EACHLABS_API_KEY", baseURL: "https://api.eachlabs.ai/v1", }); ``` -------------------------------- ### Fetch Prediction Status Source: https://docs.eachlabs.ai/api/predictions/get-prediction Examples for retrieving prediction status using cURL, Python, and JavaScript. The Python and JavaScript examples implement a polling loop to wait for completion. ```bash curl https://api.eachlabs.ai/v1/prediction/abc123-def456-ghi789 \ -H "X-API-Key: YOUR_API_KEY" ``` ```python import requests import time prediction_id = "abc123-def456-ghi789" while True: response = requests.get( f"https://api.eachlabs.ai/v1/prediction/{prediction_id}", headers={"X-API-Key": "YOUR_API_KEY"} ) data = response.json() if data["status"] in ("success", "failed", "cancelled"): break print(f"Status: {data['status']}...") time.sleep(2) if data["status"] == "success": print(f"Output: {data['output']}") else: print(f"Failed: {data.get('logs')}") ``` ```javascript async function waitForPrediction(predictionId) { while (true) { const response = await fetch( `https://api.eachlabs.ai/v1/prediction/${predictionId}`, { headers: { "X-API-Key": "YOUR_API_KEY" } } ); const data = await response.json(); if (["success", "failed", "cancelled"].includes(data.status)) { return data; } console.log(`Status: ${data.status}...`); await new Promise((r) => setTimeout(r, 2000)); } } const result = await waitForPrediction("abc123-def456-ghi789"); console.log(`Output: ${result.output}`); ``` -------------------------------- ### Get Model Details with cURL Source: https://docs.eachlabs.ai/api/overview Use this command to retrieve details for a specific AI model, such as its input parameters and capabilities. Replace YOUR_API_KEY with your actual API key. ```bash curl https://api.eachlabs.ai/v1/model?slug=flux-1-1-pro \ -H "X-API-Key: YOUR_API_KEY" ``` -------------------------------- ### Trigger Workflow Execution (JavaScript) Source: https://docs.eachlabs.ai/workflows/endpoints/trigger-workflow This JavaScript example uses the fetch API to trigger a workflow. It configures the POST request with appropriate headers and a JSON body containing inputs and a webhook URL, then logs the execution ID. ```javascript const response = await fetch( "https://workflows.eachlabs.run/api/v1/WF_ID/trigger", { method: "POST", headers: { "Content-Type": "application/json", "X-API-Key": "YOUR_API_KEY", }, body: JSON.stringify({ inputs: { prompt: "A majestic mountain landscape" }, webhook_url: "https://your-app.com/webhooks/workflow", }), } ); const { execution_id } = await response.json(); console.log(`Execution ID: ${execution_id}`); ``` -------------------------------- ### Error Response Examples Source: https://docs.eachlabs.ai/sense/endpoints/chat-completions These examples illustrate common error response bodies for different HTTP status codes. Use these to identify and handle issues like missing API keys, invalid credentials, or rate limits. ```json {"detail": "API key is required."} ``` ```json {"detail": "Invalid API key."} ``` ```json {"detail": [{"loc": ["body","messages"], "msg": "field required"}]} ``` ```json {"detail": "Rate limit exceeded."} ``` -------------------------------- ### GET /categories Source: https://docs.eachlabs.ai/llms.txt Retrieve a list of available workflow categories. ```APIDOC ## GET /categories ### Description Retrieve a list of available workflow categories. ### Method GET ### Endpoint /categories ``` -------------------------------- ### Create a New Workflow Source: https://docs.eachlabs.ai/sense/endpoints/workflow-builder Demonstrates how to initialize a new AI workflow using cURL or Python. Requires an API key in the request header. ```bash curl -X POST https://eachsense-agent.core.eachlabs.run/workflow \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "message": "Create a workflow that generates a portrait image then animates it into a 5-second video", "stream": true }' ``` ```python import requests response = requests.post( "https://eachsense-agent.core.eachlabs.run/workflow", headers={ "Content-Type": "application/json", "X-API-Key": "YOUR_API_KEY" }, json={ "message": "Create a workflow that generates a portrait then animates it", "stream": False } ) print(response.json()) ``` -------------------------------- ### GET /v1/webhooks Source: https://docs.eachlabs.ai/api/webhooks/list-webhooks Retrieve a paginated list of webhooks for your organization. ```APIDOC ## GET https://api.eachlabs.ai/v1/webhooks ### Description Retrieve a paginated list of webhooks for your organization. ### Method GET ### Endpoint https://api.eachlabs.ai/v1/webhooks ### Parameters #### Query Parameters - **limit** (integer) - Optional - Max webhooks to return (1–100), default 50 - **offset** (integer) - Optional - Number of webhooks to skip, default 0 ### Request Example curl "https://api.eachlabs.ai/v1/webhooks?limit=10" -H "X-API-Key: YOUR_API_KEY" ### Response #### Success Response (200) - **webhooks** (array) - List of webhook objects - **webhooks[].execution_id** (string | null) - Associated execution ID - **webhooks[].url** (string) - Target URL - **webhooks[].request** (string) - Original request payload - **webhooks[].headers** (object) - Headers included in the webhook - **webhooks[].source** (string) - Service that triggered the webhook - **webhooks[].created_at** (string) - ISO 8601 timestamp - **limit** (integer) - Applied limit - **offset** (integer) - Applied offset #### Response Example { "webhooks": [ { "execution_id": "abc123-def456-ghi789", "url": "https://api.example.com/webhook", "request": "{\"event\":\"prediction.completed\"}", "headers": { "Content-Type": "application/json" }, "source": "api-gateway", "created_at": "2025-12-14T10:30:00Z" } ], "limit": 50, "offset": 0 } ``` -------------------------------- ### GET /workflows/{id} Source: https://docs.eachlabs.ai/llms.txt Retrieve details for a specific workflow by its ID. ```APIDOC ## GET /workflows/{id} ### Description Retrieve details for a specific workflow by its ID. ### Method GET ### Endpoint /workflows/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the workflow. ``` -------------------------------- ### Providing Initial Request Details Source: https://docs.eachlabs.ai/sense/clarifications Include all necessary parameters in the initial request to prevent the agent from needing to ask for clarification. ```json { "messages": [{ "role": "user", "content": "Generate an anime-style portrait, 1:1 aspect ratio, cyberpunk background, neon lighting" }] } ``` -------------------------------- ### Get Public Workflow Source: https://docs.eachlabs.ai/workflows/overview Retrieves details of a publicly shared workflow. ```APIDOC ## GET /public/@{nickname}/workflows/{slug}/versions/{versionID} ### Description Get a public workflow. ### Method GET ### Endpoint /public/@{nickname}/workflows/{slug}/versions/{versionID} ### Parameters #### Path Parameters - **nickname** (string) - Required - The nickname of the workflow owner. - **slug** (string) - Required - The slug of the workflow. - **versionID** (string) - Required - The identifier for the workflow version. ``` -------------------------------- ### Parameter References (Template Syntax) Source: https://docs.eachlabs.ai/llms.txt Explains how to reference inputs and step outputs using double brace `{{ }}` template syntax and condition expressions using `$` syntax. ```APIDOC ## Parameter References (Template Syntax) Use `{{double braces}}` to reference inputs and step outputs: | Reference | Description | Example | |-----------|-------------|---------| | `{{inputs.field}}` | Workflow input | `{{inputs.prompt}}` | | `{{step_id.output}}` | Full output of a step | `{{generate.output}}` | | `{{step_id.primary}}` | Primary/first result | `{{generate.primary}}` | | `{{branch_step_id.primary}}` | Output from a parallel branch step | `{{step1_branch_0.primary}}` | Templates can be embedded in strings: `"A portrait of {{inputs.name}} in {{inputs.style}} style"` Condition expressions use `$` syntax: `$.step_id.primary`, `$.step_id.output`, `$.step_id.output.field`, `$.inputs.field` ``` -------------------------------- ### Get Execution Details Source: https://docs.eachlabs.ai/workflows/overview Retrieves the details of a specific workflow execution. ```APIDOC ## GET /executions/{executionID} ### Description Get execution details. ### Method GET ### Endpoint /executions/{executionID} ### Parameters #### Path Parameters - **executionID** (string) - Required - The unique identifier of the execution. ``` -------------------------------- ### Get Workflow Details Source: https://docs.eachlabs.ai/workflows/overview Retrieves the details of a specific workflow by its ID. ```APIDOC ## GET /workflows/{id} ### Description Get workflow details. ### Method GET ### Endpoint /workflows/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the workflow. ``` -------------------------------- ### GET /v1/webhooks/{execution_id} Source: https://docs.eachlabs.ai/api/overview Retrieve details for a specific webhook execution. ```APIDOC ## GET /v1/webhooks/{execution_id} ### Description Get detailed information regarding a specific webhook execution. ### Method GET ### Endpoint /v1/webhooks/{execution_id} ### Parameters #### Path Parameters - **execution_id** (string) - Required - The unique identifier for the webhook execution. ``` -------------------------------- ### GET /v1/model Source: https://docs.eachlabs.ai/api/overview Retrieve detailed information for a specific AI model. ```APIDOC ## GET /v1/model ### Description Get specific details for a model, including input requirements and pricing. ### Method GET ### Endpoint /v1/model ### Parameters #### Query Parameters - **slug** (string) - Required - The unique identifier for the model. ``` -------------------------------- ### Update Events Source: https://docs.eachlabs.ai/sense/endpoints/workflow-builder Example of streaming events returned during a workflow update process. ```text data: {"type":"workflow_fetched","workflow_name":"portrait-to-video","existing_steps":3} data: {"type":"workflow_built","steps_count":4,"definition":{...}} data: {"type":"workflow_updated","success":true,"workflow_id":"wf_abc123","version_id":"v2"} data: {"type":"complete","status":"ok"} data: [DONE] ``` -------------------------------- ### 500 Internal Server Error Example Source: https://docs.eachlabs.ai/errors Returned when an unexpected server-side error occurs. ```json { "error": "Failed to fetch models: internal error" } ``` -------------------------------- ### 403 Forbidden Error Example Source: https://docs.eachlabs.ai/errors Returned when an operation is not allowed, such as modifying a locked resource. ```json { "error": "Workflow is locked and cannot be modified" } ``` -------------------------------- ### Generate media using the each::sense AI agent Source: https://docs.eachlabs.ai/ Utilize the OpenAI-compatible client to interact with the each::sense agent for automated model selection and media generation. ```python from openai import OpenAI client = OpenAI( api_key="YOUR_API_KEY", base_url="https://eachsense-agent.core.eachlabs.run/v1" ) response = client.chat.completions.create( model="eachsense/beta", messages=[{"role": "user", "content": "Generate a cinematic landscape at golden hour"}], ) ``` -------------------------------- ### 400 Bad Request Error Example Source: https://docs.eachlabs.ai/errors Returned when request parameters or the body are invalid. ```json { "error": "slug parameter is required" } ``` -------------------------------- ### Get Session Memory Source: https://docs.eachlabs.ai/sense/endpoints/sessions-memory Retrieve the conversation history and memory for a specific session. ```APIDOC ## GET /memory ### Description Retrieve the conversation history and memory for a specific session. ### Method GET ### Endpoint https://eachsense-agent.core.eachlabs.run/memory ### Query Parameters - **session_id** (string) - Required - Session ID to retrieve ### Response #### Success Response (200) - **session_id** (string) - The ID of the session. - **conversation_history** (array) - An array of conversation objects, each containing timestamp, user prompt, chatbot response, and generated media URLs. - **total_exchanges** (integer) - The total number of exchanges in the conversation. - **generated_media_urls** (array) - URLs of media generated during the session. ### Request Example ```json { "session_id": "my-session" } ``` ### Response Example ```json { "session_id": "my-session", "conversation_history": [ { "timestamp": "2024-01-15T10:30:00Z", "user_prompt": "Generate a portrait", "chatbot_response": "Here's your portrait!", "generated_media_urls": ["https://storage.eachlabs.ai/xxx.png"] } ], "total_exchanges": 1, "generated_media_urls": ["https://storage.eachlabs.ai/xxx.png"] } ``` ``` -------------------------------- ### POST /workflows Source: https://docs.eachlabs.ai/llms.txt Create a new workflow instance. ```APIDOC ## POST /workflows ### Description Create a new workflow instance. ### Method POST ### Endpoint /workflows ``` -------------------------------- ### Get Prediction Endpoint Source: https://docs.eachlabs.ai/api/predictions/get-prediction The base URL for retrieving prediction status and results. ```http GET https://api.eachlabs.ai/v1/prediction/{id} ``` -------------------------------- ### Execution Events Source: https://docs.eachlabs.ai/sense/streaming/event-types Events related to the start, progress, and completion of workflow executions. ```APIDOC ## Execution Events ### `execution_started` ### Request Example ```json { "type": "execution_started", "execution_id": "exec_xyz", "workflow_id": "wf_abc123" } ``` ### `execution_progress` ### Request Example ```json { "type": "execution_progress", "step_id": "step2", "step_status": "completed", "model": "kling-2-1-image-to-video", "output": "https://storage.eachlabs.ai/video.mp4", "completed_steps": 2, "total_steps": 4, "progress_percent": 50 } ``` ### `execution_completed` ### Request Example ```json { "type": "execution_completed", "execution_id": "exec_xyz", "status": "completed", "output": "https://storage.eachlabs.ai/final.mp4", "all_outputs": { "step1": "...", "step2": "...", "step3": "..." }, "total_time_ms": 45000 } ``` ``` -------------------------------- ### List Models via cURL Source: https://docs.eachlabs.ai/sense/endpoints/models Use this cURL command to list available models. Replace YOUR_API_KEY with your actual API key. ```bash curl https://eachsense-agent.core.eachlabs.run/v1/models \ -H "X-API-Key: YOUR_API_KEY" ``` -------------------------------- ### Execution Events Source: https://docs.eachlabs.ai/sense/streaming/event-types Events tracking the start, progress, and completion of workflow executions. ```json { "type": "execution_started", "execution_id": "exec_xyz", "workflow_id": "wf_abc123" } ``` ```json { "type": "execution_progress", "step_id": "step2", "step_status": "completed", "model": "kling-2-1-image-to-video", "output": "https://storage.eachlabs.ai/video.mp4", "completed_steps": 2, "total_steps": 4, "progress_percent": 50 } ``` ```json { "type": "execution_completed", "execution_id": "exec_xyz", "status": "completed", "output": "https://storage.eachlabs.ai/final.mp4", "all_outputs": { "step1": "...", "step2": "...", "step3": "..." }, "total_time_ms": 45000 } ``` -------------------------------- ### Enable SSE Streaming with cURL Source: https://docs.eachlabs.ai/sense/streaming/overview Use this cURL command to send a POST request to the completions endpoint and enable streaming. Set `stream: true` in the request body. Ensure your API key is included in the headers. ```bash curl -N -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "messages": [{"role": "user", "content": "Generate a portrait"}], "stream": true }' ``` -------------------------------- ### Streaming Response Events Source: https://docs.eachlabs.ai/sense/endpoints/workflow-builder Example of Server-Sent Events (SSE) returned when streaming is enabled. ```text data: {"type":"status","message":"Creating workflow..."} data: {"type":"workflow_created","workflow_id":"wf_abc123","version_id":"v1","input_schema":{...},"steps_count":3} data: {"type":"text_response","content":"I've created your workflow!"} data: {"type":"complete","status":"ok","workflow_id":"wf_abc123"} data: [DONE] ``` -------------------------------- ### 429 Rate Limited Error Example Source: https://docs.eachlabs.ai/errors Returned when the request frequency exceeds allowed limits. ```json { "error": "Rate limit exceeded. Please retry after 60 seconds." } ``` -------------------------------- ### Configure AI agent client for each::sense Source: https://docs.eachlabs.ai/ Point any OpenAI-compatible framework to the each::sense base URL to enable agent-based workflows. ```python # Works with LangChain, CrewAI, AutoGen, or any OpenAI-compatible client client = OpenAI( api_key="YOUR_API_KEY", base_url="https://eachsense-agent.core.eachlabs.run/v1" ) ``` -------------------------------- ### each::workflows - Get execution details Source: https://docs.eachlabs.ai/llms.txt Retrieves detailed information about a specific workflow execution. ```APIDOC ## GET /executions/{executionID} ### Description Get execution details. ### Method GET ### Endpoint `https://workflows.eachlabs.run/api/v1/executions/{executionID}` ### Parameters #### Path Parameters - **executionID** (string) - Required - The unique identifier of the execution. ``` -------------------------------- ### Interact with each::sense using OpenAI SDK Source: https://docs.eachlabs.ai/llms.txt Configure the OpenAI client with the EachLabs base URL and perform streaming or non-streaming chat completions. ```javascript import OpenAI from "openai"; const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://eachsense-agent.core.eachlabs.run/v1" }); // Non-streaming const response = await client.chat.completions.create({ model: "eachsense/beta", messages: [{ role: "user", content: "Generate a sunset landscape" }], stream: false }); console.log(response.generations); // Streaming const stream = await client.chat.completions.create({ model: "eachsense/beta", messages: [{ role: "user", content: "Generate a sunset landscape" }], stream: true }); for await (const chunk of stream) { const eachlabs = chunk.eachlabs; if (eachlabs?.type === "generation_response") { console.log(eachlabs.generations); } } ``` -------------------------------- ### Initiate Chat Completion with Python Source: https://docs.eachlabs.ai/llm-router/models Use the client.chat.completions.create method to send a request to a specific model. Ensure the model parameter follows the provider/model-name format. ```python response = client.chat.completions.create( model="openai/gpt-4o", # any model ID from the tables below messages=[{"role": "user", "content": "Hello!"}] ) ``` -------------------------------- ### each::workflows - Get workflow Source: https://docs.eachlabs.ai/llms.txt Retrieves details of a specific workflow using its ID or slug. ```APIDOC ## GET /workflows/{id} ### Description Get workflow details. ### Method GET ### Endpoint `https://workflows.eachlabs.run/api/v1/workflows/{id}` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier (UUID or slug) of the workflow. ``` -------------------------------- ### GET /v1/prediction/{id} Source: https://docs.eachlabs.ai/api/predictions/get-prediction Retrieve the status and results of a model prediction by providing its ID. ```APIDOC ## GET /v1/prediction/{id} ### Description Retrieve the status and results of a model prediction. ### Method GET ### Endpoint https://api.eachlabs.ai/v1/prediction/{id} ### Parameters #### Path Parameters - **id** (string) - Required - Prediction ID returned from [Create Prediction](/api/predictions/create-prediction) ### Request Example ```bash curl https://api.eachlabs.ai/v1/prediction/abc123-def456-ghi789 \ -H "X-API-Key: YOUR_API_KEY" ``` ### Response #### Success Response (200) - **id** (string) - Prediction ID - **input** (object) - Input parameters used - **status** (string) - `starting`, `processing`, `success`, `failed`, or `cancelled` - **output** (string | array | object) - Prediction output (type depends on model) - **logs** (string | null) - Execution logs - **metrics.predict_time** (number) - Processing time in seconds - **metrics.cost** (number) - Cost in USD - **urls.cancel** (string) - URL to cancel the prediction - **urls.get** (string) - URL to re-fetch this prediction #### Response Example ```json { "id": "abc123-def456-ghi789", "input": { "prompt": "A beautiful sunset over the ocean with vibrant colors", "aspect_ratio": "16:9" }, "status": "success", "output": "https://storage.example.com/predictions/abc123/image.jpg", "logs": null, "metrics": { "predict_time": 12.5, "cost": 0.05 }, "urls": { "cancel": "https://api.eachlabs.ai/v1/prediction/abc123-def456-ghi789/cancel", "get": "https://api.eachlabs.ai/v1/prediction/abc123-def456-ghi789" } } ``` ### Error Responses | Status | Body | Description | | ------ | ------------------------------------ | --------------------- | | `404` | `{"error": "Prediction not found"}` | Invalid prediction ID | | `500` | `{"error": "Internal server error"}` | Server error | ```