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

# Devin SDK example: quickstart

> Two small Devin SDK programs: start a session, send a prompt, and read what Devin does as typed events, in the cloud or in the CLI locally.

> [!NOTE]
>
> Source: [`quickstart`](https://github.com/COG-GTM/devin-sdk-examples/tree/main/quickstart)

| Program | Run | What it shows |
| - | - | - |
| `stream` | `bun run stream` | The minimum: `createDevin()` → `createSession()` → `run()`, print the reply |
| `events` | `bun run events` | `switch` on every event type; each tool call with what it did (`call.detail`) |

Add `--local` to either to run in the bundled Devin CLI in the current directory instead of the
cloud. The code is identical; only `createDevin({ cwd })` changes. Add `--acp-v1` to require
[ACP v1](https://docs.devin.ai/sdk/how-it-works.md#choosing-the-acp-version) on either transport; nothing else in the
programs changes, because the session API is the same on both protocol versions.

## What `events` prints

```
$ bun run events
Creating the file, reading it back, listing the directory…      ← reasoning, dimmed
completed  write ./hello.txt
completed  read ./hello.txt
completed  $ ls -la  → exit 0
I created hello.txt with a greeting, read it back, and listed the directory.
turn ended: end_turn
--
3 tool calls, stopped: end_turn
```

`event` is a discriminated union (`SessionEvent`), so each `case` narrows it. Tool calls carry a
normalized `detail` — `exec` (command, exit code), `read`/`write`/`edit` (path), `mcp`,
`permission_request`, `ask_user_question`, … — so you never string-match titles, and the cloud's
and the CLI's different wire encodings look the same.

## Run

```sh theme={null}
git clone https://github.com/COG-GTM/devin-sdk-examples
cd devin-sdk-examples/quickstart
bun install                    # @cognition-ai/sdk from npm (the pinned beta)
export DEVIN_API_KEY=cog_…
bun run stream                 # cloud
bun run events --local         # the CLI, in this directory
bun run stream --acp-v1        # require ACP v1 instead of the v2 default
```

> [card] [How it works](https://docs.devin.ai/sdk/how-it-works.md)
>
> What differs between the two runs and what doesn't.

> [card] [Stream events](https://docs.devin.ai/sdk/guides/streaming-events.md)
>
> The full event and tool-call detail vocabulary.


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