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

# Backends

export const ViewInGithub = ({link}) => <a href={`${link}`} className="callout-link">
		<span>
            <Icon icon="github" size={24} />
            View in Github
		</span>
		<Icon icon="arrow-right" iconType="solid" />
	</a>;

<ViewInGithub link={"https://github.com/zolinthecow/enochian-js/blob/master/js/src/backends"} />

A `Backend` is an LLM provider, think OpenAI, Anthropic, etc. Enochian provides integrations
with the large providers as well as SGLang for local models.

## SGLBackend

[SGLang](https://github.com/sgl-project/sglang) is a fast local LLM inference engine. Enochian
is also heavily inspired by their frontend language!

### `setModel`

**Parameters**

* `url: string`

**Returns**

* `Promise<void>`

Setting the model in SGLang is asynchronous because it has to send a request to their URL to
get the name of the model hosted on it.

### Example

```typescript theme={null}
const s = await new ProgramState().fromSGL('http://localhost:30000');
```

## OpenAIBackend

### `setModel`

**Parameters**

* `{baseURL?: string, modelName?: ChatModel}`

**Returns**

* `Promise<void>`

**Types Referenced**:

* [`ChatModel`](https://github.com/openai/openai-node/blob/d08bf1a8fa779e6a9349d92ddf65530dd84e686d/src/resources/chat/chat.ts#L11)

Set the model and/or baseURL of the OpenAI endpoint.

### Example

```typescript theme={null}
const s = new ProgramState().fromOpenAI({ modelName: 'gpt-4o-mini' });
```

It works the same way as OpenAI's node SDK where if you don't pass in an
API key, then it will use the environment variable `OPENAI_API_KEY`.
