Prerequisites
- Node.js 22 or later.
- A Devin API key: a
cog_…personal access token, created on the PATs tab of app.devin.ai → Settings → Devin API.
Install
The
@cognition-ai packages are in beta. Every release is a 0.0.1-beta.N prerelease on the
beta dist-tag (currently 0.0.1-beta.7), so the @beta suffix is required: a bare
npm install @cognition-ai/sdk fails on purpose. Pin the exact version in your lockfile, and keep
every @cognition-ai package you use (sdk, ai-sdk, cloudflare-agents, harness-devin) on
the same version; they release together. Each published version is stable, but the API can
change between beta bumps; see the changelog for what moved.Run a session
createDevin() connects to the cloud. Pass cwd to run the bundled Devin CLI on your machine
instead. Both need an API key, from the apiKey option or DEVIN_API_KEY; nothing else in the
environment changes which one you get.
await using closes the connection (and the CLI process) at
scope exit. Call .close() yourself if you don’t use it.
Next steps
Stream events
Print the reply as it arrives and react to each tool call.
Structured output
Get a typed, validated value back instead of prose.
How it works
Run the same code in the Devin CLI on your machine with
createDevin({cwd}).Using devin.api
Read the session’s PRs and structured output, or manage playbooks and secrets.
Examples
Five runnable programs, including this quickstart with a
--local flag.SDK reference
Every exported class, function, and type, generated from the source.

