skillfed

opencode-ai

The official Python library for the opencode API

opencode-ai v0.1.0a36 116.0K downloads/30d#12,224 on PyPI270
Permissive license MIT AGING released

What it is and what it does

Opencode-ai is an official Python SDK for the Opencode REST API, generated with Stainless. It wraps HTTP calls to the Opencode service and provides both synchronous and asynchronous clients powered by httpx, with optional aiohttp backend support for improved async concurrency. All request parameters and response fields are typed using Pydantic models and TypedDicts, enabling IDE autocomplete and type checking.

The library handles common REST API concerns: automatic retries for transient failures (connection errors, timeouts, 429s, 5xx errors), configurable timeouts and retry counts, and a hierarchy of error types (APIConnectionError, APIStatusError, RateLimitError, etc.) for granular error handling. It supports streaming responses via Server Side Events and provides helpers for serializing responses to JSON or dictionaries. Runtime dependencies are minimal and stable (anyio, httpx, pydantic, distro, sniffio, typing-extensions).

Use it for:

  • Build applications that interact with Opencode sessions, events, or other resources via a type-safe Python interface
  • Integrate Opencode API calls into async Python services or event-driven architectures using AsyncOpencode
  • Stream Server Side Events from Opencode endpoints with built-in iteration support
  • Handle API errors and retries automatically without writing custom retry logic
  • Access raw HTTP response headers and metadata via .with_raw_response or .with_streaming_response

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a Python client library for the Opencode REST API with synchronous and asynchronous interfaces, type-safe request/response handling via Pydantic, and built-in error handling and retry logic.

Yes, if you need to call the Opencode API from Python. The library is well-structured with type safety, async support, and sensible defaults. However, note that it is in pre-release (0.1.0a36) and the project shows aging maintenance (last commit 2026-01-30), so expect slower updates and potential breaking changes in future releases. Verify that the Opencode service and your authentication method are available before committing to this dependency.

Install

opencode-ai on PyPI

pip

pip install opencode-ai

uv

uv add opencode-ai

poetry

poetry add opencode-ai

Installing opencode-ai

Before you install

Low install friction with a pure-Python wheel and standard dependencies. Maintenance status is aging—last commit was 2026-01-30, over 352 days since initial release—so expect slower response to issues or updates.

License in practice

MIT license is permissive; you can use this library in commercial and proprietary projects with minimal restrictions, though you must include the license notice.

Quickstart

pip install --pre opencode-ai

from opencode_ai import Opencode

client = Opencode()
sessions = client.session.list()

Requires Python 3.8 or later. API credentials or endpoint configuration may be needed depending on Opencode service requirements.

Verify before relying

  • Whether authentication (API key, token, or credentials) is required and how to configure it
  • Whether the Opencode service itself is publicly available or requires special access
  • Performance characteristics and rate-limit behavior under typical workloads
  • Stability guarantees for the 0.1.0a36 pre-release version

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 6 — anyio, distro, httpx, pydantic, sniffio, typing-extensions
Maintenance aging — 352 days since the last release
Last repo commit
First released
Downloads 115,983/month — #12,224 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: opencode_ai-0.1.0a36-py3-none-any.whl

Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: OS IndependentOperating System :: POSIXOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

opencode api clientpython rest api libraryasync http clienttyped api wrapperopencode sdkpydantic api clienthttpx async client
rest-api-clientasync-httptype-safe

More Python Modules packages