본문으로 건너뛰기

SDK

직접 만든 스크립트, CI 작업, 도구에서 OpenCode를 제어하세요. SDK는 내 설정과 모델로 OpenCode를 내 프로세스 안에서 실행하며, 타입이 지정된 클라이언트가 세션을 만들고, 프롬프트를 보내고, 모든 이벤트를 스트리밍합니다.

기능

코드로 CI 고치기

짧은 스크립트가 OpenCode에게 실패한 테스트를 고치게 한 뒤 다시 실행합니다.

모든 단계 추적

이벤트를 스트리밍해 에이전트가 호출하는 도구를 실시간으로 확인하세요.

나만의 도구 만들기

몇 줄의 코드로 OpenCode를 봇, 대시보드, 워크플로에 연결하세요.

내 프로세스 안에서

내 설정과 모델로 OpenCode를 내 프로세스 안에서 실행합니다.

  • TypeScript 클라이언트@opencode/client와 같은 값을 쓰는 타입 지정 요청과 이벤트.
  • 코드로 세션 생성어떤 스크립트에서든 세션을 만들고 프롬프트를 보내세요.
  • 모든 모델OpenCode 설정에 있는 모델을 그대로 사용합니다.
  • npm 또는 bunnpm i @opencode/sdk 또는 bun add @opencode/sdk로 설치하세요.
  • 인프로세스 호스트네트워크를 거치지 않고 메모리에서 OpenCode를 실행합니다.
  • 내 플러그인인프로세스 호스트를 만들 때 직접 만든 플러그인을 넘기세요.
  • Promise 또는 Effect같은 값을 돌려주는 Promise API와 Effect API.
  • Cloudflare WorkersWorkers의 Cloudflare Durable Object 안에서 OpenCode를 실행하세요.

  • npmnpm i @opencode/sdk
  • bunbun add @opencode/sdk
SDK 문서 읽기

변경 내역

  1. v2.2.4

    Publish Interactive Artifacts

    Enable "experimental": { "artifacts": true } in opencode.json to let agents publish, update, and serve HTML or static artifacts through the built-in local provider or plugin-provided storage.#60351

    개선 사항

    • SDKExtended client.experimental.persistentPty.update to rename terminals or clear a user title, and exposed userTitle plus persistent-pty.updated events.#60329
  2. v2.2.3

    Added lazy loading for stored image references when experimental.media_blob is enabled

    Added lazy loading for stored image references when experimental.media_blob is enabled. Images are downloaded only for previews, while undo, revert, fork, and prompt recall restore referenced attachments safely.#60116

    개선 사항

    • SDKPreserved partial LLMResponse output on AIError.partial when generation, object generation, or a tool loop fails.#60477
    • SDKUnified Effect and Promise tool declarations around tool(...), with optional output schemas and executable or declaration-only tools.#60407
    • SDKAdded typed OpenRouter debug, models, plugins, provider, and user options to the Responses route.#60044

    수정 사항

    • SDKMatched the Promise AI client more closely to the Effect API and accepted typed tools in loops.#60465#60390
    • SDKKept tools whose execute handler can throw available to the AI client.#60431
    • SDKContinued polling queued media generations when providers return unknown intermediate statuses.#59988
    • SDKStopped sending an incompatible filename alongside file_url on OpenAI Responses requests.#60382
  3. v2.2.2

    Exposed SessionInfo.time.busy for the latest execution’s start time

    개선 사항

    • SDKAdded if and until inputs for client.experimental.schedule.create, plus schedule check results and output fields.#60137
    • SDKAdded optional source metadata to prompt file attachments.
전체 업데이트 보기