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

# createDevin

```typescript
createDevin(options: CreateLocalOptions): Promise<LocalDevin>
```

Connect to Devin with a personal access token (`cog_…`), cloud or local.

`cwd` is the switch: passing one spawns the bundled Devin CLI in that
directory (`LocalDevin`); leaving it out connects to Devin's cloud over
a WebSocket (`CloudDevin`). Both need an API key, from the `apiKey` option
or `$DEVIN_API_KEY`; the environment never decides the transport.

```ts
await using cloud = await createDevin();                // apiKey from DEVIN_API_KEY
await using cloud = await createDevin({ apiKey });      // CloudDevin
await using local = await createDevin({ cwd: "/repo" }); // LocalDevin
```

Clients are async-disposable: `await using` closes the connection at scope
exit, or call `devin.close()` yourself.

## Parameters

**options** `CreateLocalOptions` *required*

## Returns

`Promise<LocalDevin>`

```typescript
createDevin(options?: CreateCloudOptions): Promise<CloudDevin>
```

Connect to Devin with a personal access token (`cog_…`), cloud or local.

`cwd` is the switch: passing one spawns the bundled Devin CLI in that
directory (`LocalDevin`); leaving it out connects to Devin's cloud over
a WebSocket (`CloudDevin`). Both need an API key, from the `apiKey` option
or `$DEVIN_API_KEY`; the environment never decides the transport.

```ts
await using cloud = await createDevin();                // apiKey from DEVIN_API_KEY
await using cloud = await createDevin({ apiKey });      // CloudDevin
await using local = await createDevin({ cwd: "/repo" }); // LocalDevin
```

Clients are async-disposable: `await using` closes the connection at scope
exit, or call `devin.close()` yourself.

## Parameters

**options** `CreateCloudOptions`

## Returns

`Promise<CloudDevin>`

```typescript
createDevin(options?: CreateDevinOptions): Promise<LocalDevin | CloudDevin>
```

Connect to Devin with a personal access token (`cog_…`), cloud or local.

`cwd` is the switch: passing one spawns the bundled Devin CLI in that
directory (`LocalDevin`); leaving it out connects to Devin's cloud over
a WebSocket (`CloudDevin`). Both need an API key, from the `apiKey` option
or `$DEVIN_API_KEY`; the environment never decides the transport.

```ts
await using cloud = await createDevin();                // apiKey from DEVIN_API_KEY
await using cloud = await createDevin({ apiKey });      // CloudDevin
await using local = await createDevin({ cwd: "/repo" }); // LocalDevin
```

Clients are async-disposable: `await using` closes the connection at scope
exit, or call `devin.close()` yourself.

## Parameters

**options** `CreateDevinOptions`

## Returns

`Promise<LocalDevin | CloudDevin>`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.