Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9b3134a
chore: sync repo
stainless-app[bot] Aug 31, 2025
979c43d
feat(api): manual updates
stainless-app[bot] Sep 3, 2025
5d58a79
feat: improve future compat with pydantic v3
stainless-app[bot] Sep 4, 2025
273dffa
chore(internal): move mypy configurations to `pyproject.toml` file
stainless-app[bot] Sep 5, 2025
0a47e60
chore(tests): simplify `get_platform` test
stainless-app[bot] Sep 6, 2025
6ae1aed
chore(internal): update pydantic dependency
stainless-app[bot] Sep 17, 2025
ed48f59
chore(types): change optional parameter type from NotGiven to Omit
stainless-app[bot] Sep 19, 2025
74f0fa2
chore: do not install brew dependencies in ./scripts/bootstrap by def…
stainless-app[bot] Sep 20, 2025
662246b
fix(compat): compat with `pydantic<2.8.0` when using additional fields
stainless-app[bot] Sep 25, 2025
932d414
chore(internal): detect missing future annotations with ruff
stainless-app[bot] Oct 11, 2025
92cb13d
chore: bump `httpx-aiohttp` version to 0.1.9
stainless-app[bot] Oct 18, 2025
81dc914
fix(client): close streams without requiring full consumption
stainless-app[bot] Oct 30, 2025
33f3521
chore(internal): codegen related update
stainless-app[bot] Oct 31, 2025
04093bb
chore(internal): codegen related update
stainless-app[bot] Nov 4, 2025
568efca
chore(internal): codegen related update
stainless-app[bot] Nov 11, 2025
0ccd3fe
chore(internal): codegen related update
stainless-app[bot] Nov 12, 2025
875138a
chore(internal): codegen related update
stainless-app[bot] Nov 22, 2025
ab5c493
chore(internal): codegen related update
stainless-app[bot] Nov 28, 2025
a59b154
chore(internal): codegen related update
stainless-app[bot] Dec 3, 2025
6c4c701
release: 0.1.0-alpha.37
stainless-app[bot] Dec 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.36"
".": "0.1.0-alpha.37"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 26
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-62d8fccba4eb8dc3a80434e0849eab3352e49fb96a718bb7b6d17ed8e582b716.yml
openapi_spec_hash: 4ff9376cf9634e91731e63fe482ea532
config_hash: 1ae82c93499b9f0b9ba828b8919f9cb3
configured_endpoints: 43
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-97b61518d8666ea7cb310af04248e00bcf8dc9753ba3c7e84471df72b3232004.yml
openapi_spec_hash: a3500531973ad999c350b87c21aa3ab8
config_hash: 026ef000d34bf2f930e7b41e77d2d3ff
349 changes: 21 additions & 328 deletions CHANGELOG.md

Large diffs are not rendered by default.

29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- prettier-ignore -->
[![PyPI version](https://img.shields.io/pypi/v/opencode-ai.svg?label=pypi%20(stable))](https://pypi.org/project/opencode-ai/)

The Opencode Python library provides convenient access to the Opencode REST API from any Python 3.8+
The Opencode Python library provides convenient access to the Opencode REST API from any Python 3.9+
application. The library includes type definitions for all request params and response fields,
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).

Expand Down Expand Up @@ -116,6 +116,31 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ

Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.

## Nested params

Nested parameters are dictionaries, typed using `TypedDict`, for example:

```python
from opencode_ai import Opencode

client = Opencode()

response = client.session.prompt(
id="id",
parts=[
{
"text": "text",
"type": "text",
}
],
model={
"model_id": "modelID",
"provider_id": "providerID",
},
)
print(response.model)
```

## Handling errors

When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `opencode_ai.APIConnectionError` is raised.
Expand Down Expand Up @@ -367,7 +392,7 @@ print(opencode_ai.__version__)

## Requirements

Python 3.8 or higher.
Python 3.9 or higher.

## Contributing

Expand Down
148 changes: 114 additions & 34 deletions api.md

Large diffs are not rendered by default.

50 changes: 0 additions & 50 deletions mypy.ini

This file was deleted.

83 changes: 70 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
[project]
name = "opencode-ai"
version = "0.1.0-alpha.36"
version = "0.1.0-alpha.37"
description = "The official Python library for the opencode API"
dynamic = ["readme"]
license = "MIT"
authors = [
{ name = "Opencode", email = "support@sst.dev" },
]

dependencies = [
"httpx>=0.23.0, <1",
"pydantic>=1.9.0, <3",
"typing-extensions>=4.10, <5",
"anyio>=3.5.0, <5",
"distro>=1.7.0, <2",
"sniffio",
"httpx>=0.23.0, <1",
"pydantic>=1.9.0, <3",
"typing-extensions>=4.10, <5",
"anyio>=3.5.0, <5",
"distro>=1.7.0, <2",
"sniffio",
]
requires-python = ">= 3.8"

requires-python = ">= 3.9"
classifiers = [
"Typing :: Typed",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Operating System :: OS Independent",
"Operating System :: POSIX",
"Operating System :: MacOS",
Expand All @@ -39,14 +41,14 @@ Homepage = "https://github.com/sst/opencode-sdk-python"
Repository = "https://github.com/sst/opencode-sdk-python"

[project.optional-dependencies]
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.8"]
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.9"]

[tool.rye]
managed = true
# version pins are in requirements-dev.lock
dev-dependencies = [
"pyright==1.1.399",
"mypy",
"mypy==1.17",
"respx",
"pytest",
"pytest-asyncio",
Expand All @@ -56,7 +58,6 @@ dev-dependencies = [
"dirty-equals>=0.6.0",
"importlib-metadata>=6.7.0",
"rich>=13.7.1",
"nest_asyncio==1.6.0",
"pytest-xdist>=3.6.1",
]

Expand Down Expand Up @@ -142,7 +143,7 @@ filterwarnings = [
# there are a couple of flags that are still disabled by
# default in strict mode as they are experimental and niche.
typeCheckingMode = "strict"
pythonVersion = "3.8"
pythonVersion = "3.9"

exclude = [
"_dev",
Expand All @@ -157,6 +158,58 @@ reportOverlappingOverload = false
reportImportCycles = false
reportPrivateUsage = false

[tool.mypy]
pretty = true
show_error_codes = true

# Exclude _files.py because mypy isn't smart enough to apply
# the correct type narrowing and as this is an internal module
# it's fine to just use Pyright.
#
# We also exclude our `tests` as mypy doesn't always infer
# types correctly and Pyright will still catch any type errors.
exclude = ['src/opencode_ai/_files.py', '_dev/.*.py', 'tests/.*']

strict_equality = true
implicit_reexport = true
check_untyped_defs = true
no_implicit_optional = true

warn_return_any = true
warn_unreachable = true
warn_unused_configs = true

# Turn these options off as it could cause conflicts
# with the Pyright options.
warn_unused_ignores = false
warn_redundant_casts = false

disallow_any_generics = true
disallow_untyped_defs = true
disallow_untyped_calls = true
disallow_subclassing_any = true
disallow_incomplete_defs = true
disallow_untyped_decorators = true
cache_fine_grained = true

# By default, mypy reports an error if you assign a value to the result
# of a function call that doesn't return anything. We do this in our test
# cases:
# ```
# result = ...
# assert result is None
# ```
# Changing this codegen to make mypy happy would increase complexity
# and would not be worth it.
disable_error_code = "func-returns-value,overload-cannot-match"

# https://github.com/python/mypy/issues/12162
[[tool.mypy.overrides]]
module = "black.files.*"
ignore_errors = true
ignore_missing_imports = true


[tool.ruff]
line-length = 120
output-format = "grouped"
Expand All @@ -173,6 +226,8 @@ select = [
"B",
# remove unused imports
"F401",
# check for missing future annotations
"FA102",
# bare except statements
"E722",
# unused arguments
Expand All @@ -195,6 +250,8 @@ unfixable = [
"T203",
]

extend-safe-fixes = ["FA102"]

[tool.ruff.lint.flake8-tidy-imports.banned-api]
"functools.lru_cache".msg = "This function does not retain type information for the wrapped function's arguments; The `lru_cache` function from `_utils` should be used instead"

Expand Down
Loading