본문으로 건너뛰기

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

    session.generate returns tokens and cost along with text

    v2.2.7의 하이라이트 모두 보기

    호환성이 깨지는 변경

    SDK: fewer endpoints wait for plugins to load

    On a Location that is still loading plugins, agent.list returns the agents loaded so far, and integration.list, usage.limits, vcs.init, rpc.call and artifact.* no longer wait up to 5 seconds. Entries and actions that a plugin provides appear when it finishes loading, so refresh on the matching *.updated event. Model, provider, generate.*, voice.* and websearch.query endpoints still wait.

    #62796#63040

    개선 사항

    • SDKcredential.updated includes the integrationID and credentialID of the login that changed.#62762
    • SDKPredicate questions in client.experimental.generate.decisions accept optional criteria: { true?, false? }.#62819
  2. v2.2.6

    Improvements

    v2.2.6의 하이라이트 모두 보기

    개선 사항

    • SDKAdded client.experimental.job.list() and its Effect equivalent for listing background shell, subagent, and image jobs, with session, descendant, kind, and status filters.#60698
    • SDKServer embedders can provide a custom fetch implementation for OpenCode HTTP, model, web, and remote MCP traffic.#61582
  3. 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

    v2.2.4의 하이라이트 모두 보기

    개선 사항

    • SDKExtended client.experimental.persistentPty.update to rename terminals or clear a user title, and exposed userTitle plus persistent-pty.updated events.#60329
전체 업데이트 보기