### Run bundle example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agents.md Example of launching an agent instance. ```python agent = client.agents.bundles.run(bundle_id, source=[file_id]) agent_id = agent["id"] ``` -------------------------------- ### requests_get usage example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/base.md Demonstrates how to perform a GET request to retrieve file information. ```python data = client.files.requests_get( client.files._get_endpoint(client.files.api_endpoint, "files/info")) ``` -------------------------------- ### Create bundle example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agents.md Example of creating a new bundle from a blueprint. ```python bundle = client.agents.bundles.create(blueprint="mga", name="my-mga") bundle_id = bundle["id"] ``` -------------------------------- ### Run OSM Agent with custom data Source: https://github.com/archetypeai/python-client/blob/main/README.md Prepares and runs the OSM agent lifecycle example using custom data from the LARCO quickstart repository. ```bash git clone https://github.com/archetypeai/operational-state-monitoring-agent-example-larco-quickstart.git cd operational-state-monitoring-agent-example-larco-quickstart git lfs pull && python prep/archive_roles.py --unpack cd - python -m examples.agents.agent_osm_lifecycle --api_key= \ --data_dir=operational-state-monitoring-agent-example-larco-quickstart/data/roles ``` -------------------------------- ### Verify installation Source: https://github.com/archetypeai/python-client/blob/main/README.md Run this command in your terminal to confirm the client is installed and check its version. ```bash python -c "from archetypeai import ArchetypeAI; print(f'Version: {ArchetypeAI.get_version()}')" ``` -------------------------------- ### GET agents/evals/{eval_id}/examples Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/endpoints.md Retrieves examples for a specific eval. Supports pagination. ```APIDOC ## GET agents/evals/{eval_id}/examples ### Description Retrieves examples for a specific eval. Supports pagination. ### Method GET ### Endpoint agents/evals/{eval_id}/examples ### Parameters #### Path Parameters - **eval_id** (string) - Required - Eval ID #### Query Parameters - **limit** (integer) - Optional - Pagination limit - **after** (string) - Optional - Pagination cursor - **before** (string) - Optional - Pagination cursor ### Response #### Success Response (200) - **dict** - Examples ``` -------------------------------- ### List bundles example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agents.md Example of listing bundles filtered by a query string. ```python page = client.agents.bundles.list(query="Quick Start") ``` -------------------------------- ### Get agent instance usage Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agent-instances.md Example of retrieving a specific agent instance and printing its status. ```python agent = client.agents.instances.get(agent_id) print(agent["status"]) ``` -------------------------------- ### Run bundle with error handling example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agents.md Example of running a bundle and waiting for completion with error handling. ```python from archetypeai import ApiError try: agent = client.agents.bundles.run(bundle_id, source=[file_id]) result = client.agents.instances.wait_until_done(agent["id"], timeout_sec=600) if result.get("status") != "completed": print(client.agents.instances.get_events(agent["id"])) except ApiError as err: # HTTP 400–416 responses print("Launch failed:", err) ``` -------------------------------- ### EvalsApi.create Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/evals-optimizations.md Creates and starts an eval for a blueprint on labeled examples. Returns the eval metadata with its id. ```APIDOC ## POST agents/evals ### Description Creates and starts an eval for a blueprint on labeled examples. Returns the eval metadata with its id. ### Method POST ### Endpoint agents/evals ### Parameters #### Request Body - **blueprint_id** (str) - Required - blp_ ID to evaluate - **examples** (list[str | dict]) - Required - File IDs or example dicts, e.g. {"inputs": [{"type": "file", "id": "file_abc123"}], "ground_truth": {...}}; a bare file ID works when the file carries labels in a column named after the target (e.g. state for OSM) - **name** (str) - Optional - Eval name (default "") - **primary** (str | None) - Optional - Override primary metric, e.g. state.macro_f1 - **targets** (dict | None) - Optional - Override scoring targets - **emit_predictions** (bool | None) - Optional - Override whether predictions are emitted ### Request Example { "blueprint_id": "blp_123", "examples": ["file_abc123"], "name": "OSM lifecycle example: test" } ### Response #### Success Response (200) - **id** (string) - The eval ID #### Response Example { "id": "evl_123" } ``` -------------------------------- ### LensSessionSocket usage example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/sse-sockets.md Example demonstrating how to initialize the socket, send a request, and close the connection. ```python from archetypeai._lens_session_socket import LensSessionSocket socket = LensSessionSocket("wss://.../lens-session", {"Authorization": "Bearer YOUR_KEY"}) reply = socket.send_and_recv({"type": "session.read", "event_data": {"client_id": "my-client"}}) socket.close() ``` -------------------------------- ### Delete bundle example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agents.md Example of deleting a bundle. ```python client.agents.bundles.delete(bundle_id) ``` -------------------------------- ### Get blueprint details with BlueprintsApi.get Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agents.md Retrieves details for a specific blueprint using its ID or key. The example fetches the blueprint with the key 'mga' and extracts its ID. ```python blueprint = client.agents.blueprints.get("mga") mga_id = blueprint["id"] ``` -------------------------------- ### ServerSideEventsReader usage example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/sse-sockets.md Example demonstrating how to initialize the reader, iterate over events, and close the connection. ```python from archetypeai._sse import ServerSideEventsReader reader = ServerSideEventsReader( "https://.../api/lens/sessions/consumer/ses_123", {"Authorization": "Bearer YOUR_KEY"}, max_read_time_sec=60.0, ) for event in reader.read(block=True): print(event["type"], event.get("event_data")) reader.close() ``` -------------------------------- ### Get Node Registry Usage Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agents.md Example of calling the get_node_registry method to retrieve available nodes. ```python registry = client.agents.get_node_registry() ``` -------------------------------- ### Install Archetype AI via pip Source: https://github.com/archetypeai/python-client/blob/main/README.md Use pip to install the Archetype AI client package. ```bash pip install archetypeai ``` -------------------------------- ### get Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/evals-optimizations.md Gets one optimization by its opt_ ID, with trial progress (progress) and best_trial. HTTP: GET agents/optimizations/{optimization_id}. ```APIDOC ## GET agents/optimizations/{optimization_id} ### Description Gets one optimization by its opt_ ID, with trial progress (progress) and best_trial. ### Method GET ### Endpoint agents/optimizations/{optimization_id} ### Parameters #### Path Parameters - **optimization_id** (str) - Required - The opt_ ID of the optimization. ### Response #### Success Response (200) - **id** (str) - The optimization ID. - **progress** (object) - Trial progress information. - **best_trial** (object) - The best trial information. #### Response Example { "id": "opt_123", "progress": { "completed": 2, "total": 5 }, "best_trial": { "id": "trial_1", "objective_value": 0.85 } } ``` -------------------------------- ### Initialize ArchetypeAI client with constructor options Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/configuration.md Example of instantiating the ArchetypeAI client with custom configuration parameters. ```python client = ArchetypeAI( api_key="KEY", api_endpoint="https://platform.u1.archetypeai.app/api", num_retries=5, client_id="my-cluster-node-1", request_timeout_sec=180, ) ``` -------------------------------- ### create Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/evals-optimizations.md Creates and starts an optimization. HTTP: POST agents/optimizations. ```APIDOC ## POST agents/optimizations ### Description Creates and starts an optimization. The body includes blueprint_id, objective, validation_examples, budget with max_trials, name, and optional training_examples, calibration_examples, search_space, overrides, constraints. Returns metadata with id. ### Method POST ### Endpoint agents/optimizations ### Parameters #### Request Body - **blueprint_id** (str) - Required - The blp_ ID to search. - **objective** (str) - Required - One of the blueprint's metrics, e.g. macro_f1. - **validation_examples** (list[str | dict]) - Required - Score each trial against these. - **max_trials** (int) - Required - Budget: at most this many trials. - **training_examples** (list[str | dict] | None) - Optional - Fit each trial on these. - **calibration_examples** (list[str | dict] | None) - Optional - Optional calibration set. - **search_space** (dict | None) - Optional - What trials sample, e.g. {"parameters": {"k_neighbors": {"kind": "value", "spec": {"type": "categorical", "values": [5, 31]}}}}. - **overrides** (dict | None) - Optional - Blueprint values/models for every trial, e.g. {"values": {"states": ["idle", "running"]}}; values the blueprint marks required must be set here. - **constraints** (dict | None) - Optional - Constraint overrides. - **name** (str) - Optional - Optimization name. Defaults to "". ### Request Example { "blueprint_id": "blp_123", "objective": "macro_f1", "validation_examples": ["example1", "example2"], "budget": { "max_trials": 2 }, "name": "OSM search", "training_examples": ["example1", "example2"], "calibration_examples": null, "search_space": { "parameters": { "window_size": { "kind": "value", "spec": { "type": "categorical", "values": [512] } }, "k_neighbors": { "kind": "value", "spec": { "type": "categorical", "values": [5, 31] } } } }, "overrides": { "values": { "states": ["idle", "running"], "timestamp_column": "ts", "data_columns": ["col1", "col2"] } }, "constraints": null } ### Response #### Success Response (200) - **id** (str) - The optimization ID. #### Response Example { "id": "opt_123" } ``` -------------------------------- ### FilePartReader usage example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/direct-upload.md Example of using FilePartReader as a context manager to read a chunk from a file. ```python from archetypeai._direct_upload import FilePartReader with FilePartReader("data.csv", offset=0, length=1024) as reader: chunk = reader.read(256) assert len(reader) == 1024 ``` -------------------------------- ### Download a File Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/files.md Example of downloading a file and checking the success status. ```python ok = client.files.local.download("video.mp4", "local_copy.mp4") if not ok: print("download failed") ``` -------------------------------- ### Build Archetype AI from source Source: https://github.com/archetypeai/python-client/blob/main/README.md Clone the repository and install the package directly from the source code. ```bash git clone git@github.com:archetypeai/python-client.git cd python-client python -m pip install . ``` -------------------------------- ### get Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agents.md Gets a single bundle by its bnd_ ID. ```APIDOC ## GET agents/bundles/{bundle_id} ### Description Gets a single bundle by its bnd_ ID. ### Method GET ### Endpoint agents/bundles/{bundle_id} ### Parameters #### Path Parameters - **bundle_id** (str) - Required - The bnd_ ID of the bundle ### Response #### Success Response (200) - **dict** - Bundle details #### Response Example ```python { "id": "bnd_123" } ``` ``` -------------------------------- ### EvalsApi.list_examples Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/evals-optimizations.md Lists what the eval measured for each example, in the order given. ```APIDOC ## GET agents/evals/{eval_id}/examples ### Description Lists what the eval measured for each example, in the order given. ### Method GET ### Endpoint agents/evals/{eval_id}/examples ### Parameters #### Path Parameters - **eval_id** (str) - Required - The evl_ ID of the eval #### Query Parameters - **limit** (int | None) - Optional - Page size - **after** (str | None) - Optional - Previous page's next_cursor - **before** (str | None) - Optional - Previous page's prev_cursor ### Response #### Success Response (200) - **examples** (array) - List of example measurements #### Response Example { "examples": [] } ``` -------------------------------- ### _get_endpoint usage example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/base.md Demonstrates how to construct a URL endpoint using the _get_endpoint method. ```python client.files._get_endpoint(client.files.api_endpoint, "files", "info") # https://platform.u1.archetypeai.app/api/files/info ``` -------------------------------- ### get Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agents.md Retrieves a single blueprint by reference (ID or key). Corresponds to HTTP GET agents/blueprints/{reference}. ```APIDOC ## GET agents/blueprints/{reference} ### Description Retrieves a single blueprint by reference (ID or key). ### Method GET ### Endpoint agents/blueprints/{reference} ### Parameters #### Path Parameters - **reference** (str) - Required - `blp_` ID or blueprint key (e.g. `tva`, `mga`, `osm`) #### Query Parameters - **yaml** (bool | None) - Optional - `True` always include the YAML rendering; `False` never include it; omit for server default ### Request Example ```python blueprint = client.agents.blueprints.get("mga") ``` ### Response #### Success Response (200) - **id** (string) - The blueprint ID #### Response Example ```python mga_id = blueprint["id"] ``` ``` -------------------------------- ### requests_download usage example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/base.md Demonstrates downloading a file and writing the content to a local file if the request is successful. ```python response = client.files.local.requests_download( client.files.local._get_endpoint(client.files.local.api_endpoint, "files/download/some.mp4")) if response.status_code == 200: open("out.mp4", "wb").write(response.content) ``` -------------------------------- ### get Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agent-instances.md Gets a single agent instance by its ID. The response includes the instance status. ```APIDOC ## get ### Description Gets a single instance. HTTP: `GET agents/instances/{agent_id}`. Response includes `status`. ### Method GET ### Endpoint `agents/instances/{agent_id}` ### Parameters #### Path Parameters - **agent_id** (str) - Required - The ID of the agent instance to retrieve. ### Request Example ```python agent = client.agents.instances.get(agent_id) print(agent["status"]) ``` ### Response #### Success Response (200) Returns a dictionary representing the agent instance, including its `status`. #### Response Example ```python { "status": "running" } ``` ``` -------------------------------- ### Eval example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/types.md One labeled example for evals/optimizations. A plain string is normalized to a dict with inputs containing a file reference. Full dict form includes optional ground_truth. ```APIDOC ## Eval example ### Description One labeled example for evals/optimizations. A plain string is normalized to a dict with inputs containing a file reference. Full dict form includes optional ground_truth. ### Normalized form (plain string) {"inputs": [{"type": "file", "id": "file_abc123"}]} ### Full dict form { "inputs": [{"type": "file", "id": "file_abc123"}], "ground_truth": {"state": {"from": {"column": "label"}}}, # alternative: {"state": {"from": {"constant": "spin"}}} } ### Accepted by - EvalsApi.create (examples) - OptimizationsApi.create (training_examples, validation_examples, calibration_examples) ``` -------------------------------- ### OptimizationsApi create method Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/evals-optimizations.md Defines the method signature for creating and starting an optimization. ```python def create( self, blueprint_id: str, objective: str, validation_examples: list[str | dict], max_trials: int, training_examples: list[str | dict] | None = None, calibration_examples: list[str | dict] | None = None, search_space: dict | None = None, overrides: dict | None = None, constraints: dict | None = None, name: str = "", ) -> dict: ``` -------------------------------- ### iter_metadata Usage Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/files.md Example of iterating through all file metadata. ```python for file_meta in client.files.iter_metadata(): print(file_meta["file_id"]) ``` -------------------------------- ### Promote a trial example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/evals-optimizations.md Promotes a specific trial to a new blueprint using its ID. ```python blueprint = client.agents.optimizations.promote_trial(optimization_id, best_trial["id"]) promoted_id = blueprint["id"] ``` -------------------------------- ### Basic File Upload Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/files.md A simple example of uploading a file using the default proxy settings. ```python response = client.files.local.upload("video.mp4") file_id = response["file_id"] ``` -------------------------------- ### get_file_type usage example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/base.md Demonstrates mapping a file extension to its corresponding MIME type. ```python mime = client.files.local.get_file_type("video.mp4") # "video/mp4" ``` -------------------------------- ### get_info Usage Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/files.md Example of calling get_info to retrieve organization file statistics. ```python info = client.files.get_info() ``` -------------------------------- ### Delete a File Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/files.md Example of deleting a file by its name. ```python client.files.local.delete("video.mp4") ``` -------------------------------- ### List agent instances usage Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agent-instances.md Example of listing agent instances filtered by the 'running' status. ```python page = client.agents.instances.list(status="running") ``` -------------------------------- ### Advanced File Upload with Progress and Cancellation Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/files.md An example demonstrating direct upload with progress tracking, cancellation, and resume capabilities. ```python import threading cancel = threading.Event() def on_progress(completed_parts, total_parts, completed_bytes, total_bytes): print(f"{completed_parts}/{total_parts} parts, {completed_bytes}/{total_bytes} bytes") response = client.files.local.upload( "large_sensor_log.csv", use_proxy=False, max_workers=16, on_progress=on_progress, cancel_event=cancel, allow_resume=True, # reuse a previous in-progress upload disable_checkpointing=False, ) file_id = response["file_id"] ``` -------------------------------- ### requests_post usage example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/base.md Shows how to send a JSON-encoded payload using the POST method. ```python import json result = api.requests_post( endpoint, data_payload=json.dumps({"key": "value"}), additional_headers={"Content-Type": "application/json"}, ) ``` -------------------------------- ### Create and wait for an evaluation Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/evals-optimizations.md Example workflow to create an evaluation, wait for its completion, and print the primary metric results. ```python evaluation = client.agents.evals.create( blueprint_id, examples=[labeled_file_id], name="OSM lifecycle example: test", ) evaluation = client.agents.evals.wait_until_done(evaluation["id"]) primary = (evaluation.get("metrics_report") or {}).get("primary") print(primary.get("target"), primary.get("name"), primary.get("value")) ``` -------------------------------- ### pformat usage Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/utils.md Example of using pformat to format and print a dictionary as a YAML string with a prefix. ```python from archetypeai import pformat print(pformat(prefix=f"Agent results:\n", data={"status": "completed", "results": []})) ``` -------------------------------- ### GET agents/blueprints/{reference}/versions Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/endpoints.md Retrieves a page of versions for a specific blueprint. ```APIDOC ## GET agents/blueprints/{reference}/versions ### Description Retrieves a page of versions for a specific blueprint. ### Method GET ### Endpoint agents/blueprints/{reference}/versions ### Parameters #### Path Parameters - **reference** (string) - Required - Blueprint reference (blp_ ID or key) #### Query Parameters - **limit** (integer) - Optional - Pagination limit - **after** (string) - Optional - Pagination cursor ### Response #### Success Response (200) - **dict** - Page of versions #### Response Example { "data": [] } ``` -------------------------------- ### get_results usage example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agent-instances.md Retrieves output references produced by the specified agent instance, returned in order from newest to oldest. ```python results = client.agents.instances.get_results(agent_id) ``` -------------------------------- ### GET agents/blueprints Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/endpoints.md Retrieves a page of blueprints. Supports pagination and filtering by key. ```APIDOC ## GET agents/blueprints ### Description Retrieves a page of blueprints. ### Method GET ### Endpoint agents/blueprints ### Parameters #### Query Parameters - **limit** (integer) - Optional - Pagination limit - **after** (string) - Optional - Pagination cursor - **key** (string) - Optional - Filter by key ### Response #### Success Response (200) - **dict** - Page of blueprints #### Response Example { "data": [] } ``` -------------------------------- ### Create an optimization example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/evals-optimizations.md Demonstrates how to initiate an optimization search with specific training data, validation data, and search space parameters. ```python optimization = client.agents.optimizations.create( blueprint_id=osm_blueprint_id, objective="macro_f1", training_examples=training_examples, validation_examples=validation_examples, max_trials=2, search_space={"parameters": { "window_size": {"kind": "value", "spec": {"type": "categorical", "values": [512]}}, "k_neighbors": {"kind": "value", "spec": {"type": "categorical", "values": [5, 31]}}, }}, overrides={"values": {"states": states, "timestamp_column": ts, "data_columns": cols}}, name="OSM search", ) optimization_id = optimization["id"] ``` -------------------------------- ### EvalsApi list_examples method definition Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/evals-optimizations.md Defines the method to list measurements for each example within an evaluation. ```python def list_examples( self, eval_id: str, limit: int | None = None, after: str | None = None, before: str | None = None ) -> dict: ``` -------------------------------- ### list Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agents.md Lists blueprints visible to your org, newest first. Corresponds to HTTP GET agents/blueprints. ```APIDOC ## GET agents/blueprints ### Description Lists blueprints visible to your org, newest first. ### Method GET ### Endpoint agents/blueprints ### Parameters #### Query Parameters - **limit** (int | None) - Optional - Page size (server default) - **after** (str | None) - Optional - ID of the last item of the previous page (pagination) - **key** (str | None) - Optional - Filter to a single blueprint key, e.g. `osm` ### Request Example ```python page = client.agents.blueprints.list(key="osm", limit=10) ``` ### Response #### Success Response (200) - **data** (array) - List of blueprint objects, each containing `id` and `blueprint_key` #### Response Example ```python for bp in page["data"]: print(bp["id"], bp["blueprint_key"]) ``` ``` -------------------------------- ### get_logs usage example Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agent-instances.md Retrieves run logs for an agent instance, filtered by the specified log level. ```python page = client.agents.instances.get_logs(agent_id, level="error") ``` -------------------------------- ### Initialize ArchetypeAI client Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/archetypeai.md Demonstrates basic client instantiation using the default endpoint and a customized configuration with retries and timeouts. ```python from archetypeai import ArchetypeAI client = ArchetypeAI("your-api-key") # default endpoint client = ArchetypeAI( "your-api-key", api_endpoint="https://platform.u1.archetypeai.app/api", num_retries=5, request_timeout_sec=120, ) ``` -------------------------------- ### list_versions Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agents.md Lists all versions of a blueprint key, newest first. Corresponds to HTTP GET agents/blueprints/{reference}/versions. ```APIDOC ## GET agents/blueprints/{reference}/versions ### Description Lists all versions of a blueprint key, newest first. ### Method GET ### Endpoint agents/blueprints/{reference}/versions ### Parameters #### Path Parameters - **reference** (str) - Required - Blueprint key or ID #### Query Parameters - **limit** (int | None) - Optional - Page size (server default) - **after** (str | None) - Optional - ID of the last item of the previous page (pagination) ### Request Example ```python versions = client.agents.blueprints.list_versions("osm") ``` ### Response #### Success Response (200) - **data** (array) - List of version objects ``` -------------------------------- ### get_metadata Usage Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/files.md Examples of using get_metadata for paginated retrieval and fetching a single file's metadata. ```python page = client.files.get_metadata(limit=10) while page["has_more"]: page = client.files.get_metadata(limit=10, after=page["next_cursor"]) meta = client.files.get_metadata(file_id="file_abc123") ``` -------------------------------- ### OptimizationsApi get method Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/evals-optimizations.md Retrieves details for a specific optimization by its ID, including trial progress and the best trial. ```python def get(self, optimization_id: str) -> dict: ``` -------------------------------- ### get_metadata Method Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/lens.md Retrieves metadata for lenses. The example demonstrates fetching metadata for a specific lens and accessing its configuration. ```python def get_metadata(self, shard_index: int = -1, max_items_per_shard: int = -1, lens_id: str = "") -> dict: ``` ```python metadata = client.lens.get_metadata(lens_id=lens_id) lens_config = metadata[0]["lens_config"] ``` -------------------------------- ### Example usage of direct_upload Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/direct-upload.md Demonstrates how to initiate a direct upload using the ArchetypeAI client, including progress tracking, cancellation, and resume support. ```python from archetypeai import ArchetypeAI import threading client = ArchetypeAI("api-key") cancel = threading.Event() def progress(parts_done, parts_total, bytes_done, bytes_total): print(f"{parts_done}/{parts_total} parts ({bytes_done}/{bytes_total} bytes)") result = client.files.local.upload( "dataset.csv", use_proxy=False, # triggers direct_upload max_workers=16, on_progress=progress, cancel_event=cancel, allow_resume=True, ) print(result["file_id"]) ``` -------------------------------- ### run Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agents.md Launches a new agent instance from a bundle and returns its metadata. Accepts source inputs and an optional sink for output. ```APIDOC ## POST agents/bundles/{bundle_id}/run ### Description Launches a new agent instance and returns its metadata (with id). Strings are normalized to {"type": "file", "id": ref} by _as_data_ref. ### Method POST ### Endpoint agents/bundles/{bundle_id}/run ### Parameters #### Path Parameters - **bundle_id** (str) - Required - bnd_ ID to run #### Request Body - **source** (list[str | dict]) - Required - Inputs: each is a file ID string or a data ref dict, e.g. {"type": "file", "id": "file_abc123", "format": "csv"} — must match the bundle's input format - **sink** (str | dict | None) - Optional - Direct all output to a single ref; default is one output per input ### Request Example ```python agent = client.agents.bundles.run(bundle_id, source=[file_id]) agent_id = agent["id"] ``` ### Response #### Success Response (200) - **dict** - Agent instance metadata #### Response Example ```python { "id": "agent_123" } ``` ### Error Handling - **ApiError** - HTTP 400–416 responses ### Example with Error Handling ```python from archetypeai import ApiError try: agent = client.agents.bundles.run(bundle_id, source=[file_id]) result = client.agents.instances.wait_until_done(agent["id"], timeout_sec=600) if result.get("status") != "completed": print(client.agents.instances.get_events(agent["id"])) except ApiError as err: # HTTP 400–416 responses print("Launch failed:", err) ``` ``` -------------------------------- ### Run MGA Quick Start agent Source: https://github.com/archetypeai/python-client/blob/main/README.md Executes a Manual Generation (MGA) agent on a procedure video. Replace with your actual API key. ```bash python -m examples.quickstart --api_key= ``` -------------------------------- ### Run OSM Agent lifecycle example Source: https://github.com/archetypeai/python-client/blob/main/README.md Runs an Operational State Monitoring (OSM) agent through its full lifecycle using default sample data. ```bash python -m examples.agents.agent_osm_lifecycle --api_key= ``` -------------------------------- ### AgentsApi.get_node_registry Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agents.md Gets the registry of connector and processing nodes available to blueprints. HTTP: GET agents/nodes/registry. ```APIDOC ## GET agents/nodes/registry ### Description Gets the registry of connector and processing nodes available to blueprints. ### Method GET ### Endpoint agents/nodes/registry ### Parameters None ### Request Example None ### Response #### Success Response (200) - **body** (dict) - Parsed JSON response body containing the node registry. #### Response Example { "nodes": [] } ``` -------------------------------- ### create Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agents.md Creates a bundle owned by your org, ready to run. Accepts blueprint ID or key, name, description, and optional model, value, and artifact overrides. ```APIDOC ## POST agents/bundles ### Description Creates a bundle owned by your org, ready to run. ### Method POST ### Endpoint agents/bundles ### Parameters #### Request Body - **blueprint** (str) - Required - blp_ ID or key (e.g. mga) - **name** (str) - Required - Bundle name - **description** (str) - Optional - Bundle description (default "") - **models** (dict | None) - Optional - Per-slot model override, e.g. {"vision": "omega-1.5"}; omit → blueprint defaults - **values** (dict | None) - Optional - Blueprint value overrides - **artifacts** (dict | None) - Optional - Artifact references ### Request Example ```python bundle = client.agents.bundles.create(blueprint="mga", name="my-mga") bundle_id = bundle["id"] ``` ### Response #### Success Response (200) - **dict** - Created bundle details #### Response Example ```python { "id": "bnd_123" } ``` ``` -------------------------------- ### POST files/uploads/initiate Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/endpoints.md Initiates a direct upload session, returning presigned URLs for uploading parts. ```APIDOC ## POST files/uploads/initiate ### Description Initiates a direct upload session. ### Method POST ### Endpoint files/uploads/initiate ### Parameters #### Request Body - **filename** (string) - Required - The name of the file - **file_type** (string) - Required - The MIME type of the file - **num_bytes** (integer) - Required - The size of the file in bytes - **resume_if_started** (boolean) - Optional - Whether to resume an existing upload ### Request Example { "filename": "string", "file_type": "string", "num_bytes": 0, "resume_if_started": false } ### Response #### Success Response (200) - **upload_id** (string) - The ID of the upload session - **presigned_urls** (array) - URLs for uploading parts #### Response Example { "upload_id": "string", "presigned_urls": [] } ``` -------------------------------- ### FilesApi.get_info Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/files.md Gets high-level file info for all files your org uploaded (e.g. counts/storage). HTTP: GET files/info. ```APIDOC ## GET files/info ### Description Gets high-level file info for all files your org uploaded (e.g. counts/storage). ### Method GET ### Endpoint files/info ### Parameters None ### Request Example ```python info = client.files.get_info() ``` ### Response #### Success Response (200) - **info** (dict) - High-level file info including counts and storage. #### Response Example ```json { "info": {} } ``` ``` -------------------------------- ### create_and_run_lens Method Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/lens.md Registers a lens, executes a session callback, and optionally cleans up resources. The example shows passing a YAML configuration string and a callback function. ```python def create_and_run_lens( self, lens_config: str | dict, session_fn: Callable, auto_destroy_lens: bool = True, auto_destroy_session: bool = True, **session_kwargs ): ``` ```python client.lens.create_and_run_lens( """ lens_name: Sensor Log Detector lens_config: model_parameters: model_version: Newton::c2_4_7b_251215a172f6d7 instruction: Analyze the sensor logs focus: find anomalies output_streams: - stream_type: server_sent_events_writer """, session_callback, client=client, args=args, ) ``` -------------------------------- ### Get agent instance method definition Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agent-instances.md The get method definition for retrieving a single agent instance by its ID. ```python def get(self, agent_id: str) -> dict: ``` -------------------------------- ### OptimizationsApi promote_trial method Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/evals-optimizations.md Defines the method signature for promoting a completed trial to a new blueprint. ```python def promote_trial( self, optimization_id: str, trial_id: str, blueprint_key: str | None = None, name: str | None = None, description: str | None = None, ) -> dict: ``` -------------------------------- ### Eval example payload shape Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/types.md The structure for evaluation examples, which can be a simple list of inputs or a full dictionary including ground truth. ```python {"inputs": [{"type": "file", "id": "file_abc123"}]} ``` ```python { "inputs": [{"type": "file", "id": "file_abc123"}], "ground_truth": {"state": {"from": {"column": "label"}}}, # label in a column # alternative: {"state": {"from": {"constant": "spin"}}} # constant label } ``` -------------------------------- ### ArchetypeAI.__init__ Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/archetypeai.md Constructor for the ArchetypeAI client. Initializes the client with an API key and optional endpoint and configuration options. ```APIDOC ## ArchetypeAI.__init__ ### Description Initializes the ArchetypeAI client with the provided API key and optional endpoint. It also accepts additional configuration options for retries, client ID, and request timeout. ### Method Constructor ### Signature ```python def __init__(self, api_key: str, api_endpoint: str = DEFAULT_ENDPOINT, **kwargs) -> None: ``` ### Parameters - **api_key** (str) - Required - Your Archetype AI API key. - **api_endpoint** (str) - Optional - Platform host followed by /api. Default is "https://platform.u1.archetypeai.app/api". - **kwargs** - Optional - Filtered by signature for each sub-API constructor. Accepted keys: num_retries, client_id, request_timeout_sec. ### Example ```python from archetypeai import ArchetypeAI client = ArchetypeAI("your-api-key") # default endpoint client = ArchetypeAI( "your-api-key", api_endpoint="https://platform.u1.archetypeai.app/api", num_retries=5, request_timeout_sec=120, ) ``` ### Error Handling An invalid status code in 400-416 range raises ApiError. ``` -------------------------------- ### FilesApi.get_metadata Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/files.md Fetches metadata for files, either as a paginated page or for a single file by ID. HTTP: GET files/metadata or GET files/metadata/{file_id}. ```APIDOC ## GET files/metadata ### Description Fetches metadata for files, either as a paginated page or for a single file by ID. ### Method GET ### Endpoint files/metadata ### Parameters #### Query Parameters - **limit** (int) - Optional - Page size (server default 100, at most 1000) - **after** (string) - Optional - next_cursor of previous page (forward pagination) - **before** (string) - Optional - prev_cursor of previous page (backward pagination); mutually exclusive with after - **file_id** (string) - Optional - If set, fetches metadata for a single file instead of a page ### Request Example ```python page = client.files.get_metadata(limit=10) while page["has_more"]: page = client.files.get_metadata(limit=10, after=page["next_cursor"]) meta = client.files.get_metadata(file_id="file_abc123") ``` ### Response #### Success Response (200) - **data** (array) - List of file metadata objects - **has_more** (boolean) - Whether there are more pages - **next_cursor** (string or null) - Cursor for next page - **prev_cursor** (string or null) - Cursor for previous page #### Response Example ```json { "data": [], "has_more": false, "next_cursor": null, "prev_cursor": null } ``` ``` -------------------------------- ### get_events Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agent-instances.md Gets the lifecycle event log of an agent instance. Useful for debugging failures. Corresponds to HTTP GET agents/instances/{agent_id}/events. ```APIDOC ## GET agents/instances/{agent_id}/events ### Description Gets the lifecycle event log of an instance. Useful for debugging failures. ### Method GET ### Endpoint agents/instances/{agent_id}/events ### Parameters #### Path Parameters - **agent_id** (str) - Required - The `agt_` ID of the agent instance. ### Response #### Success Response (200) Returns a dictionary containing the lifecycle event log. ### Example ```python events = client.agents.instances.get_events(agent_id) ``` ``` -------------------------------- ### get_results Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agent-instances.md Gets output references produced by the agent instance, newest first. Supports pagination with limit and after parameters. Corresponds to HTTP GET agents/instances/{agent_id}/results. ```APIDOC ## GET agents/instances/{agent_id}/results ### Description Gets output refs produced by the instance, newest first. ### Method GET ### Endpoint agents/instances/{agent_id}/results ### Parameters #### Path Parameters - **agent_id** (str) - Required - The `agt_` ID of the agent instance. #### Query Parameters - **limit** (int | None) - Optional - Page size. Default: None. - **after** (str | None) - Optional - Previous page's `next_cursor`. Default: None. ### Response #### Success Response (200) Returns a dictionary containing the output references. ### Example ```python results = client.agents.instances.get_results(agent_id) ``` ``` -------------------------------- ### get_logs Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agent-instances.md Gets the run logs of an agent instance, newest first. Supports pagination, filtering by log level, and substring search. Corresponds to HTTP GET agents/instances/{agent_id}/logs. ```APIDOC ## GET agents/instances/{agent_id}/logs ### Description Gets the run logs, newest first. ### Method GET ### Endpoint agents/instances/{agent_id}/logs ### Parameters #### Path Parameters - **agent_id** (str) - Required - The `agt_` ID of the agent instance. #### Query Parameters - **limit** (int | None) - Optional - Page size. Default: None. - **after** (str | None) - Optional - Previous page's `next_cursor`. Default: None. - **level** (str | None) - Optional - Filter, e.g. `error`. Default: None. - **search** (str | None) - Optional - Substring match on message and event type. Default: None. ### Response #### Success Response (200) Returns a dictionary containing the run logs. ### Example ```python page = client.agents.instances.get_logs(agent_id, level="error") ``` ``` -------------------------------- ### GET agents/nodes/registry Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/endpoints.md Retrieves the registry of nodes. ```APIDOC ## GET agents/nodes/registry ### Description Retrieves the registry of nodes. ### Method GET ### Endpoint agents/nodes/registry ### Response #### Success Response (200) - **dict** - Registry ``` -------------------------------- ### GET agents/optimizations/{optimization_id} Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/endpoints.md Retrieves a specific optimization by ID. ```APIDOC ## GET agents/optimizations/{optimization_id} ### Description Retrieves a specific optimization by ID. ### Method GET ### Endpoint agents/optimizations/{optimization_id} ### Parameters #### Path Parameters - **optimization_id** (string) - Required - Optimization ID ### Response #### Success Response (200) - **dict** - Optimization #### Response Example { "id": "opt_123" } ``` -------------------------------- ### GET agents/evals/{eval_id} Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/endpoints.md Retrieves a specific eval by ID. ```APIDOC ## GET agents/evals/{eval_id} ### Description Retrieves a specific eval by ID. ### Method GET ### Endpoint agents/evals/{eval_id} ### Parameters #### Path Parameters - **eval_id** (string) - Required - Eval ID ### Response #### Success Response (200) - **dict** - Eval #### Response Example { "id": "evl_123" } ``` -------------------------------- ### GET agents/bundles/{bundle_id} Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/endpoints.md Retrieves a specific bundle by ID. ```APIDOC ## GET agents/bundles/{bundle_id} ### Description Retrieves a specific bundle by ID. ### Method GET ### Endpoint agents/bundles/{bundle_id} ### Parameters #### Path Parameters - **bundle_id** (string) - Required - Bundle ID ### Response #### Success Response (200) - **dict** - Bundle #### Response Example { "id": "bnd_123" } ``` -------------------------------- ### Run unit tests for the Python client Source: https://github.com/archetypeai/python-client/blob/main/README.md Install the test dependencies and execute the test suite using pytest. Ensure you provide your API key and endpoint as environment variables. ```bash pip install -e '.[test]' ATAI_API_KEY="your api key" ATAI_API_ENDPOINT="your api endpoint" python -m pytest . ``` -------------------------------- ### POST agents/optimizations Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/endpoints.md Creates a new optimization. Accepts JSON body with blueprint_id, objective, validation_examples, budget, name, and optional training_examples, calibration_examples, search_space, overrides, constraints. ```APIDOC ## POST agents/optimizations ### Description Creates a new optimization. Accepts JSON body with blueprint_id, objective, validation_examples, budget, name, and optional training_examples, calibration_examples, search_space, overrides, constraints. ### Method POST ### Endpoint agents/optimizations ### Parameters #### Request Body - **blueprint_id** (string) - Required - Blueprint ID - **objective** (string) - Required - Objective - **validation_examples** (array) - Required - Validation examples - **budget** (object) - Required - Budget configuration - **max_trials** (integer) - Required - Maximum number of trials - **name** (string) - Required - Optimization name - **training_examples** (array) - Optional - Training examples - **calibration_examples** (array) - Optional - Calibration examples - **search_space** (object) - Optional - Search space - **overrides** (object) - Optional - Overrides - **constraints** (array) - Optional - Constraints ### Request Example { "blueprint_id": "blp_123", "objective": "maximize accuracy", "validation_examples": [], "budget": { "max_trials": 10 }, "name": "My Optimization" } ### Response #### Success Response (201/202) - **dict** - Optimization metadata #### Response Example { "id": "opt_123" } ``` -------------------------------- ### List blueprint versions with BlueprintsApi.list_versions Source: https://github.com/archetypeai/python-client/blob/main/_autodocs/api-reference/agents.md Lists all versions of a specific blueprint key, ordered from newest to oldest. ```python versions = client.agents.blueprints.list_versions("osm") ```