# 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)


---

# Agent Instructions: 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:

```
GET https://docs.degirum.com/degirumjs/guides/connection-modes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
