What is an agent SDK? Claude, Codex, Cursor and Grok

By

An agent SDK is a library that runs an agent from your own program. How Claude Code, the Codex SDK, Cursor's two packages, and Grok Build differ.

An agent SDK is a library your program calls to run an agent without sitting in a terminal: your code starts the task, and the SDK runs the agent loop and returns the result.

How to use the OpenAI Agents API covers OpenAI’s split between the hosted Agents API, the in-app Agents SDK, and the manual Responses API. Below are the libraries Claude Code, Codex, and Cursor document (Grok Build documents none under that name).

How an agent SDK works

The terminal CLI and the library share the same harness for model calls, tools, and sessions, except your program sends the messages instead of you typing them.

You still pick the model, instructions, and allowed tools: headless mode is the one-shot CLI version, while an SDK is the library you import.

Your program driving an agent SDKYour program starts a thread and sends a task. The SDK runs the agent loop and tools, then returns the final response to your program.Your programSDK starts a threadAgent loop and toolsFinal response backto your program

Agent SDK in each tool

Claude CodeCodexCursorGrok Build
LibraryAgent SDK, Python and TypeScript. It runs the Claude Code binary@openai/codex-sdk on Node, openai-codex on Python. Local Codex threadsTwo packages. @cursor/sdk calls the IDE agent. @grok/agent-sdk defines an agent as codeNot documented. grok -p and ACP are the programmatic paths
Who runs the loopThe SDK, in a process you operateThe SDK, against local Codex@cursor/sdk runs Cursor’s agent. Agent SDK runs a loop you defined in filesYou write it, if you call the API yourself
Hosted alternativeManaged Agents, on Anthropic’s sideThe Agents API, covered in the post linked aboveCloud runtime in @cursor/sdk, or Cursor-managed hosting for Agent SDKThe API. Not a Build SDK

Claude Code

The Agent SDK exposes Claude Code’s binary (tools, permissions, sessions, hooks) from Python or TypeScript, sitting between the interactive CLI, the low-level Client SDK, and hosted Managed Agents.

Third-party products need Anthropic approval before offering claude.ai login or consumer limits, so the quickstart documents API key auth. See the Agent SDK overview.

OpenAI Codex

The Codex SDK drives local Codex from your code: TypeScript (@openai/codex-sdk, server-side on Node.js 18+) opens threads with startThread() and sends prompts with run(), while Python (openai-codex, Python 3.10+) talks to the local app-server.

The page lists CI, an internal tool, and embedding Codex in your own application. It points custom clients that need their own transcript and approval UI at the app server, not at this SDK. The Agents API in the post above is the hosted harness. This SDK is the local one. See the Codex SDK.

Cursor

Cursor documents two libraries, and they do not do the same job.

@cursor/sdk calls the agent that runs in the IDE, the CLI, and the web app. A local runtime runs the loop in your Node process against files on disk. A cloud runtime runs in a Cursor-hosted VM with the repo cloned in.

The Agent SDK, package @grok/agent-sdk, used to be @cursor/bdk. You define the agent as Markdown and TypeScript. Cursor runs the model loop that calls your tools. The page says that harness is the one behind Bugbot, Security Review, Approval Bot, and Rollouts. Install is npm install --global @grok/agent-sdk, then agent-sdk init. See Cursor TypeScript SDK and Agent SDK.

Grok Build

The Build overview does not document a library named a Grok Build SDK. The programmatic paths it does document are headless grok -p and the Agent Client Protocol.

The same page shows how to call grok-4.7 on the xAI API from the Vercel AI SDK, the OpenAI SDK, or xai_sdk. That snippet is a model call. You still write the loop around it. See Grok Build.

Details checked against each vendor’s documentation in November 2026.

A real example

This is the Codex SDK page’s TypeScript shape. It runs server-side, with the Codex SDK installed and a Codex login available to that process:

import { Codex } from '@openai/codex-sdk'

const codex = new Codex()
const thread = codex.startThread()
const result = await thread.run(
  'Make a plan to diagnose and fix the CI failures'
)

console.log(result.finalResponse)

run() again on the same thread continues the conversation. resumeThread() picks up a past one by id. The page uses those two when the plan should be implemented in a later step.

LangChain and LangGraph is the other place on this site where the loop lives in your TypeScript app, with a pause for approval. That guide is not the Codex SDK.

When to use an agent SDK

Use one when a program has to start the agent. A CI job, a bot, or a button in your own app are that case. Claude’s overview sends interactive daily work to the CLI instead.

Pick the OpenAI Agents API (from the post linked at the top) when you want OpenAI to host the session and harness, @cursor/sdk when scripting Cursor’s own agent, and @grok/agent-sdk when defining a new agent from a folder of files.

Skip the SDK when you are already in the terminal and the task is one conversation. Headless mode covers the one-shot command if you only need a script.

Pitfalls

Claude Agent SDK, Codex SDK, Cursor’s @cursor/sdk, and Cursor’s @grok/agent-sdk are four separate libraries: @grok/agent-sdk defines standalone agents, whereas scripting the Cursor IDE agent requires @cursor/sdk.

Claude’s overview blocks claude.ai login for third-party products built on the Agent SDK, unless that use was approved. The API key in the quickstart is the path the page allows.

Codex’s TypeScript SDK runs server-side rather than in the browser, and its Python SDK talks to a local Codex app-server with a pinned CLI runtime (using a different codex binary requires an explicit option).

Grok Build’s API sample is a single generateText or responses.create call. It does not start a grok session, and it does not load the project’s MCP servers for you.

  • Headless mode: Headless mode runs a coding agent from a script, with no chat UI. How claude -p, codex exec, the Cursor CLI and grok -p differ on permissions.
  • Agent loop: The agent loop is the cycle a coding agent repeats: look, act, check, and go again. How Claude Code names that cycle, and what the other tools document.
  • Coding agent: A coding agent uses a model and tools to read a repo, edit files and run commands in a loop. How Claude Code, Codex, Cursor and Grok Build each do that job.

All AI glossary entries → · AI for coding hub →

Want me to talk about your product? You can sponsor this site.