> For the complete documentation index, see [llms.txt](https://docs.coreterminal.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coreterminal.ai/product/technical-architecture/ai-resource-layer.md).

# AI Resource Layer

The AI Resource Layer manages the registration, listing, and allocation of AI infrastructure resources such as network bandwidth, GPUs, CPUs, storage, and computing power. This layer ensures efficient resource utilization and availability for AI model training and execution. This includes:

* **Resource Registration**: Allows users to register their AI resources.
* **Resource Discovery:** Identifies available computing resources, such as GPUs, CPUs, and storage, from various providers.
* **Resource Listing**: Displays available resources for lease or purchase.
* **Resource Allocation:** Dynamically allocates these resources based on demand and availability to ensure efficient utilization.
* **Resource Monitoring:** Continuously monitors resource usage to optimize performance and ensure reliability.

Code for Resource Management (Node.js with Express)

```javascript
const express = require('express');
const router = express.Router();

// Sample data
let resources = [
    { id: 1, type: 'GPU', owner: '0xOwnerAddress1', price: 10, available: true },
    { id: 2, type: 'CPU', owner: '0xOwnerAddress2', price: 5, available: true }
];

// Register a new resource
router.post('/register', (req, res) => {
    const { id, type, owner, price } = req.body;
    resources.push({ id, type, owner, price, available: true });
    res.status(201).send('Resource registered');
});

// List all resources
router.get('/list', (req, res) => {
    res.json(resources);
});

// Allocate resource
router.post('/allocate/:id', (req, res) => {
    const resourceId = parseInt(req.params.id);
    const resource = resources.find(r => r.id === resourceId);

    if (resource && resource.available) {
        resource.available = false;
        res.send('Resource allocated');
    } else {
        res.status(404).send('Resource not available');
    }
});

module.exports = router;

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.coreterminal.ai/product/technical-architecture/ai-resource-layer.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
