Cloud or local: one option
createDevin() connects to Devin’s cloud over a WebSocket and returns a CloudDevin. Pass cwd
and it spawns the Devin CLI bundled with the SDK instead, returning a LocalDevin. Nothing else
decides which you get, and TypeScript narrows the return type from the options you pass.
cog_… API key, from the apiKey option or DEVIN_API_KEY. Both implement the
same DevinClient interface, and their sessions share run(), send(), stream() and
cancel(), so code that drives a session does not know where it runs:
The quickstart example runs the same two programs against either with a
--local flag; the code is identical, only createDevin({ cwd }) changes.
Choosing the ACP version
Both transports speak the Agent Client Protocol. The agent selects the protocol version duringinitialize: the SDK offers a version, and the agent answers
with the one it will speak. By default the SDK offers ACP v2 and accepts an agent that selects v1,
so a v1-only agent still works. To require v1 instead, for example because the rest of your
stack speaks the stable v1 protocol, pass acpVersion: 1 (since 0.0.1-beta.6):
acpVersion: 1 the SDK sends only v1 initialize fields (clientCapabilities,
clientInfo) and rejects an agent that selects v2. The same option exists on
CloudDevin.connect and LocalDevin.start, and devin.protocolVersion reports what was
selected. Values other than 1 or 2 are rejected.
Application code does not change with the version. createSession(), loadSession(), run(),
send() and events() pick the matching protocol methods (session/load on v1,
session/resume on v2) and completion signal (the prompt result on v1, the idle state_update
on v2), and SessionEventReducer turns either version’s updates into the same typed
SessionEvents. Two things are v2-only: turn_state events, and the replay: "tail" and
replay: "none" options of a cloud loadSession (v1’s session/load always replays the whole
transcript). Raw ACP updates keep their version-specific shapes.
Where the API client fits
A session object covers live interaction: prompts, streaming events, permissions, cancel. It does not cover what happens around sessions, and neither does the CLI. That is the Devin REST API, andCloudDevin exposes a typed client for it as
devin.api, already authenticated with your key:
Local sessions
The bundled CLI, its state directory, permissions and file access.
Cloud sessions
Resume, attach, base URLs and organizations.
Environments
Point either client at a deployment other than production.
SDK reference
createDevin, CloudDevin, LocalDevin, and every session and event type.
