# Architecture and Connection Modes

## Connection Modes

DeGirumJS offers three easy ways to connect for AI inference:

### Local Server

Inference runs on your own AI Server (e.g., on your machine or LAN). No internet needed, but you do need your own model zoo ready.

{% code overflow="wrap" %}

```js
const dg = new dg_sdk();
const zoo = await dg.connect('localhost:8779'); // IP/Port of an AI Server on your network
const models = await zoo.listModels();
console.log('Local models:', Object.keys(models));
```

{% endcode %}

### Hybrid (Local + Cloud Models)

Inference still runs on your local AI Server, but models are loaded from the DeGirum Cloud Zoo.

{% code overflow="wrap" %}

```js
const dg = new dg_sdk();
const zoo = await dg.connect(
  'localhost:8779',                         // IP/Port of an AI Server on your network
  'https://cs.degirum.com/degirum/public', // or another Cloud Zoo URL from AI Hub
  'YOUR_TOKEN'                              // your AI Hub access token
);
const models = await zoo.listModels();
console.log('Cloud models via local server:', Object.keys(models));
```

{% endcode %}

### Cloud Only

Everything runs in the DeGirum Cloud - ideal for scalable, managed inference.

{% code overflow="wrap" %}

```js
const dg = new dg_sdk();
const zoo = await dg.connect(
  'cloud',
  'https://cs.degirum.com/degirum/public',  // or another Cloud Zoo URL from AI Hub
  'YOUR_TOKEN'                              // your AI Hub access token
);
const models = await zoo.listModels();
console.log('Cloud models:', Object.keys(models));
```

{% endcode %}

***

For more information on setting up your AI Server, refer to the [AI Server documentation](https://docs.degirum.com/pysdk/user-guide-pysdk/setting-up-an-ai-server)
