> ## Documentation Index
> Fetch the complete documentation index at: https://docs.archetypeai.app/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Start with /introduction/getting-started. Use the Direct Query API (POST /query) with the Newton Fusion model (text, image, and video reasoning) or the Newton Omega encoder (time-series embeddings). ATAI_API_ENDPOINT must include the version path: /v0.5 for most APIs, /v0.6 for the Fine-Tuning Service. Pages whose descriptions are marked (Archived) document the legacy Lens runtime — do not use them for new projects.

# Managing Agents Using the Agents API

> An introduction to using the Agents API to create, run, and manage agents.

## Creating an Agent Using an Agent Blueprint

Use the [Create Bundle](/api-reference/agents/create-bundle) endpoint to create an agent bundle
using an agent blueprint.

<CodeGroup>
  ```bash cURL theme={"system"}
  curl -X POST -H "Authorization: Bearer $ATAI_API_KEY" -H "Content-Type: application/json" \
    "$ATAI_API_ENDPOINT/agents/bundle" -d '{
      "blueprint": "osm",
      "name": "My agent name",
      "values": {"window_size": 16, "step_size": 1,
                 "sample_rate_interval_tolerance": 10.0, "max_temporal_gap": 10.0},
      "artifacts": {"fit-classifier": "s3://my-aws-folder/fit-classifier-name.safetensors"}
    }'
  ```

  ```python Python theme={"system"}
  import os

  import requests

  api_key = os.environ["ATAI_API_KEY"]
  endpoint = os.environ["ATAI_API_ENDPOINT"]

  payload = {
    "blueprint": "osm",
    "name": "My agent name",
    "values": {
      "window_size": 16,
      "step_size": 1,
      "sample_rate_interval_tolerance": 10.0,
      "max_temporal_gap": 10.0,
    },
    "artifacts": {
      "fit-classifier": "s3://my-aws-folder/fit-classifier-name.safetensors"
    },
  }

  response = requests.post(
    f"{endpoint}/agents/bundle",
    headers={
      "Authorization": f"Bearer {api_key}",
      "Content-Type": "application/json",
    },
    json=payload,
    timeout=60
  )
  ```

  ```javascript JavaScript theme={"system"}
  const apiKey = process.env.ATAI_API_KEY;
  const endpoint = process.env.ATAI_API_ENDPOINT;

  const payload = {
    blueprint: "osm",
    name: "My agent name",
    values: {
      window_size: 16,
      step_size: 1,
      sample_rate_interval_tolerance: 10.0,
      max_temporal_gap: 10.0,
    },
    artifacts: {
      "fit-classifier": "s3://my-aws-folder/fit-classifier-name.safetensors",
    },
  };

  const response = await fetch(`${endpoint}/agents/bundle`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${apiKey}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(payload)
  });
  ```
</CodeGroup>

This example creates an agent based on the Operational State Monitoring (OSM) agent blueprint,
giving the new agent the name "My agent name", providing a Safetensors file as a fit classifier
artifact, and providing several custom configuration options (`window_size`, `step_size`,
`sample_rate_interval_tolerance`, and `max_temporal_gap`).

## Running an Agent

Once an agent has been created, you can run it using the [Run
Bundle](/api-reference/agents/run-bundle) endpoint.

<CodeGroup>
  ```bash cURL theme={"system"}
  curl -X POST -H "Authorization: Bearer $ATAI_API_KEY" -H "Content-Type: application/json" \
    "$ATAI_API_ENDPOINT/agents/bundle/$BUNDLE_ID/run" -d '{
      "connectors": {"source": [{"type": "file", "id": "sample-data.csv"}]}
    }'
  ```

  ```python Python theme={"system"}
  import os

  import requests

  api_key = os.environ["ATAI_API_KEY"]
  endpoint = os.environ["ATAI_API_ENDPOINT"]
  bundle_id = os.environ["BUNDLE_ID"]

  payload = {
    "connectors": {
      "source": [{"type": "file", "id": "sample-data.csv"}]
    }
  }

  response = requests.post(
    f"{endpoint}/agents/bundle/{bundle_id}/run",
    headers={
      "Authorization": f"Bearer {api_key}",
      "Content-Type": "application/json",
    },
    json=payload,
    timeout=60
  )
  ```

  ```javascript JavaScript theme={"system"}
  const apiKey = process.env.ATAI_API_KEY;
  const endpoint = process.env.ATAI_API_ENDPOINT;
  const bundleId = process.env.BUNDLE_ID;

  const payload = {
    connectors: {
      source: [{ type: "file", id: "sample-data.csv" }],
    },
  };

  const response = await fetch(`${endpoint}/agents/bundle/${bundleId}/run`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${apiKey}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(payload)
  });
  ```
</CodeGroup>

This code uses the agent to process the data in a CSV file named `sample-data.csv` which has
already been uploaded to the Archetype Platform using the [Files API](/core-concepts/files).

## Related Content

* [Managing Agents Using the Developer Console](/developer-console/agents/overview)
