opencode-ai
The official Python library for the opencode API
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-aiuv
uv add opencode-aipoetry
poetry add opencode-aiInstalling 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
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
agentex-clientProvides a typed Python REST client for the…
permissive · top 15,000 on PyPI
arcadepyProvides a typed Python client library for the…
permissive · top 15,000 on PyPI
composio-clientA Python client library for the Composio REST…
permissive · top 5,000 on PyPI
hiddenlayer-sdkProvides a typed Python client for the…
permissive · top 15,000 on PyPI
linq-pythonA Python SDK for the Linq API V3 REST API,…
permissive · top 15,000 on PyPI
openlayerProvides a typed Python client for the…
permissive · top 15,000 on PyPI
orb-billingA Python client library for the Orb billing…
permissive · top 5,000 on PyPI
parallel-webProvides a Python client library for the…
permissive · top 5,000 on PyPI
retell-sdkProvides a Python client library for the Retell…
permissive · top 15,000 on PyPI
letta-clientProvides a Python client library for the Letta…
permissive · top 15,000 on PyPI