Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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.1"
".": "0.1.0-alpha.2"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 16
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-3c79948402e96d2aae6e46095db2cf80759750d1b042d6f91281a72c415b14de.yml
openapi_spec_hash: f9c2fc5988f0a30397929995c2be2c85
config_hash: fddca9bc092956a3e82f3f3bdba448d1
config_hash: d4c4c71d9a092267df2d4ab61fd89e63
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.1.0-alpha.2 (2025-06-27)

Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/sst/opencode-sdk-python/compare/v0.1.0-alpha.1...v0.1.0-alpha.2)

### Features

* **api:** update via SDK Studio ([a6cf7c5](https://github.com/sst/opencode-sdk-python/commit/a6cf7c5b2a411503294088428ca7918226eca161))

## 0.1.0-alpha.1 (2025-06-27)

Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/sst/opencode-sdk-python/compare/v0.0.1-alpha.0...v0.1.0-alpha.1)
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ $ pip install -r requirements-dev.lock

Most of the SDK is generated code. Modifications to code will be persisted between generations, but may
result in merge conflicts between manual patches and changes from the generator. The generator will never
modify the contents of the `src/opencode/lib/` and `examples/` directories.
modify the contents of the `src/opencode_ai/lib/` and `examples/` directories.

## Adding and running examples

Expand Down
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Opencode Python API library

[![PyPI version](<https://img.shields.io/pypi/v/opencode.svg?label=pypi%20(stable)>)](https://pypi.org/project/opencode/)
[![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+
application. The library includes type definitions for all request params and response fields,
Expand All @@ -16,15 +16,15 @@ The REST API documentation can be found on [opencode.ai](https://opencode.ai/doc

```sh
# install from PyPI
pip install --pre opencode
pip install --pre opencode-ai
```

## Usage

The full API of this library can be found in [api.md](api.md).

```python
from opencode import Opencode
from opencode_ai import Opencode

client = Opencode()

Expand All @@ -37,7 +37,7 @@ Simply import `AsyncOpencode` instead of `Opencode` and use `await` with each AP

```python
import asyncio
from opencode import AsyncOpencode
from opencode_ai import AsyncOpencode

client = AsyncOpencode()

Expand All @@ -59,15 +59,15 @@ You can enable this by installing `aiohttp`:

```sh
# install from PyPI
pip install --pre opencode[aiohttp]
pip install --pre opencode-ai[aiohttp]
```

Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:

```python
import asyncio
from opencode import DefaultAioHttpClient
from opencode import AsyncOpencode
from opencode_ai import DefaultAioHttpClient
from opencode_ai import AsyncOpencode


async def main() -> None:
Expand All @@ -91,27 +91,27 @@ Typed requests and responses provide autocomplete and documentation within your

## 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.APIConnectionError` is raised.
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.

When the API returns a non-success status code (that is, 4xx or 5xx
response), a subclass of `opencode.APIStatusError` is raised, containing `status_code` and `response` properties.
response), a subclass of `opencode_ai.APIStatusError` is raised, containing `status_code` and `response` properties.

All errors inherit from `opencode.APIError`.
All errors inherit from `opencode_ai.APIError`.

```python
import opencode
from opencode import Opencode
import opencode_ai
from opencode_ai import Opencode

client = Opencode()

try:
client.event.list()
except opencode.APIConnectionError as e:
except opencode_ai.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
except opencode.RateLimitError as e:
except opencode_ai.RateLimitError as e:
print("A 429 status code was received; we should back off a bit.")
except opencode.APIStatusError as e:
except opencode_ai.APIStatusError as e:
print("Another non-200-range status code was received")
print(e.status_code)
print(e.response)
Expand Down Expand Up @@ -139,7 +139,7 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
You can use the `max_retries` option to configure or disable retry settings:

```python
from opencode import Opencode
from opencode_ai import Opencode

# Configure the default for all requests:
client = Opencode(
Expand All @@ -157,7 +157,7 @@ By default requests time out after 1 minute. You can configure this with a `time
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:

```python
from opencode import Opencode
from opencode_ai import Opencode

# Configure the default for all requests:
client = Opencode(
Expand Down Expand Up @@ -209,7 +209,7 @@ if response.my_field is None:
The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,

```py
from opencode import Opencode
from opencode_ai import Opencode

client = Opencode()
response = client.event.with_raw_response.list()
Expand All @@ -219,9 +219,9 @@ event = response.parse() # get the object that `event.list()` would have return
print(event)
```

These methods return an [`APIResponse`](https://github.com/sst/opencode-sdk-python/tree/main/src/opencode/_response.py) object.
These methods return an [`APIResponse`](https://github.com/sst/opencode-sdk-python/tree/main/src/opencode_ai/_response.py) object.

The async client returns an [`AsyncAPIResponse`](https://github.com/sst/opencode-sdk-python/tree/main/src/opencode/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
The async client returns an [`AsyncAPIResponse`](https://github.com/sst/opencode-sdk-python/tree/main/src/opencode_ai/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.

#### `.with_streaming_response`

Expand Down Expand Up @@ -283,7 +283,7 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c

```python
import httpx
from opencode import Opencode, DefaultHttpxClient
from opencode_ai import Opencode, DefaultHttpxClient

client = Opencode(
# Or use the `OPENCODE_BASE_URL` env var
Expand All @@ -306,7 +306,7 @@ client.with_options(http_client=DefaultHttpxClient(...))
By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.

```py
from opencode import Opencode
from opencode_ai import Opencode

with Opencode() as client:
# make requests here
Expand Down Expand Up @@ -334,8 +334,8 @@ If you've upgraded to the latest version but aren't seeing any new features you
You can determine the version that is being used at runtime with:

```py
import opencode
print(opencode.__version__)
import opencode_ai
print(opencode_ai.__version__)
```

## Requirements
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ or products provided by Opencode, please follow the respective company's securit

### Opencode Terms and Policies

Please contact support@sst.dev for any questions or concerns regarding the security of our services.
Please contact hello@sst.dev for any questions or concerns regarding the security of our services.

---

Expand Down
44 changes: 22 additions & 22 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
# Shared Types

```python
from opencode.types import ProviderAuthError, UnknownError
from opencode_ai.types import ProviderAuthError, UnknownError
```

# Event

Types:

```python
from opencode.types import EventListResponse
from opencode_ai.types import EventListResponse
```

Methods:

- <code title="get /event">client.event.<a href="./src/opencode/resources/event.py">list</a>() -> <a href="./src/opencode/types/event_list_response.py">EventListResponse</a></code>
- <code title="get /event">client.event.<a href="./src/opencode_ai/resources/event.py">list</a>() -> <a href="./src/opencode_ai/types/event_list_response.py">EventListResponse</a></code>

# App

Types:

```python
from opencode.types import App, AppInitResponse
from opencode_ai.types import App, AppInitResponse
```

Methods:

- <code title="get /app">client.app.<a href="./src/opencode/resources/app.py">get</a>() -> <a href="./src/opencode/types/app.py">App</a></code>
- <code title="post /app/init">client.app.<a href="./src/opencode/resources/app.py">init</a>() -> <a href="./src/opencode/types/app_init_response.py">AppInitResponse</a></code>
- <code title="get /app">client.app.<a href="./src/opencode_ai/resources/app.py">get</a>() -> <a href="./src/opencode_ai/types/app.py">App</a></code>
- <code title="post /app/init">client.app.<a href="./src/opencode_ai/resources/app.py">init</a>() -> <a href="./src/opencode_ai/types/app_init_response.py">AppInitResponse</a></code>

# File

Types:

```python
from opencode.types import FileSearchResponse
from opencode_ai.types import FileSearchResponse
```

Methods:

- <code title="get /file">client.file.<a href="./src/opencode/resources/file.py">search</a>(\*\*<a href="src/opencode/types/file_search_params.py">params</a>) -> <a href="./src/opencode/types/file_search_response.py">FileSearchResponse</a></code>
- <code title="get /file">client.file.<a href="./src/opencode_ai/resources/file.py">search</a>(\*\*<a href="src/opencode_ai/types/file_search_params.py">params</a>) -> <a href="./src/opencode_ai/types/file_search_response.py">FileSearchResponse</a></code>

# Config

Types:

```python
from opencode.types import (
from opencode_ai.types import (
Config,
Keybinds,
McpLocal,
Expand All @@ -59,15 +59,15 @@ from opencode.types import (

Methods:

- <code title="get /config">client.config.<a href="./src/opencode/resources/config.py">get</a>() -> <a href="./src/opencode/types/config.py">Config</a></code>
- <code title="get /config/providers">client.config.<a href="./src/opencode/resources/config.py">providers</a>() -> <a href="./src/opencode/types/config_providers_response.py">ConfigProvidersResponse</a></code>
- <code title="get /config">client.config.<a href="./src/opencode_ai/resources/config.py">get</a>() -> <a href="./src/opencode_ai/types/config.py">Config</a></code>
- <code title="get /config/providers">client.config.<a href="./src/opencode_ai/resources/config.py">providers</a>() -> <a href="./src/opencode_ai/types/config_providers_response.py">ConfigProvidersResponse</a></code>

# Session

Types:

```python
from opencode.types import (
from opencode_ai.types import (
FilePart,
Message,
MessagePart,
Expand All @@ -91,13 +91,13 @@ from opencode.types import (

Methods:

- <code title="post /session">client.session.<a href="./src/opencode/resources/session.py">create</a>() -> <a href="./src/opencode/types/session.py">Session</a></code>
- <code title="get /session">client.session.<a href="./src/opencode/resources/session.py">list</a>() -> <a href="./src/opencode/types/session_list_response.py">SessionListResponse</a></code>
- <code title="delete /session/{id}">client.session.<a href="./src/opencode/resources/session.py">delete</a>(id) -> <a href="./src/opencode/types/session_delete_response.py">SessionDeleteResponse</a></code>
- <code title="post /session/{id}/abort">client.session.<a href="./src/opencode/resources/session.py">abort</a>(id) -> <a href="./src/opencode/types/session_abort_response.py">SessionAbortResponse</a></code>
- <code title="post /session/{id}/message">client.session.<a href="./src/opencode/resources/session.py">chat</a>(id, \*\*<a href="src/opencode/types/session_chat_params.py">params</a>) -> <a href="./src/opencode/types/message.py">Message</a></code>
- <code title="post /session/{id}/init">client.session.<a href="./src/opencode/resources/session.py">init</a>(id, \*\*<a href="src/opencode/types/session_init_params.py">params</a>) -> <a href="./src/opencode/types/session_init_response.py">SessionInitResponse</a></code>
- <code title="get /session/{id}/message">client.session.<a href="./src/opencode/resources/session.py">messages</a>(id) -> <a href="./src/opencode/types/session_messages_response.py">SessionMessagesResponse</a></code>
- <code title="post /session/{id}/share">client.session.<a href="./src/opencode/resources/session.py">share</a>(id) -> <a href="./src/opencode/types/session.py">Session</a></code>
- <code title="post /session/{id}/summarize">client.session.<a href="./src/opencode/resources/session.py">summarize</a>(id, \*\*<a href="src/opencode/types/session_summarize_params.py">params</a>) -> <a href="./src/opencode/types/session_summarize_response.py">SessionSummarizeResponse</a></code>
- <code title="delete /session/{id}/share">client.session.<a href="./src/opencode/resources/session.py">unshare</a>(id) -> <a href="./src/opencode/types/session.py">Session</a></code>
- <code title="post /session">client.session.<a href="./src/opencode_ai/resources/session.py">create</a>() -> <a href="./src/opencode_ai/types/session.py">Session</a></code>
- <code title="get /session">client.session.<a href="./src/opencode_ai/resources/session.py">list</a>() -> <a href="./src/opencode_ai/types/session_list_response.py">SessionListResponse</a></code>
- <code title="delete /session/{id}">client.session.<a href="./src/opencode_ai/resources/session.py">delete</a>(id) -> <a href="./src/opencode_ai/types/session_delete_response.py">SessionDeleteResponse</a></code>
- <code title="post /session/{id}/abort">client.session.<a href="./src/opencode_ai/resources/session.py">abort</a>(id) -> <a href="./src/opencode_ai/types/session_abort_response.py">SessionAbortResponse</a></code>
- <code title="post /session/{id}/message">client.session.<a href="./src/opencode_ai/resources/session.py">chat</a>(id, \*\*<a href="src/opencode_ai/types/session_chat_params.py">params</a>) -> <a href="./src/opencode_ai/types/message.py">Message</a></code>
- <code title="post /session/{id}/init">client.session.<a href="./src/opencode_ai/resources/session.py">init</a>(id, \*\*<a href="src/opencode_ai/types/session_init_params.py">params</a>) -> <a href="./src/opencode_ai/types/session_init_response.py">SessionInitResponse</a></code>
- <code title="get /session/{id}/message">client.session.<a href="./src/opencode_ai/resources/session.py">messages</a>(id) -> <a href="./src/opencode_ai/types/session_messages_response.py">SessionMessagesResponse</a></code>
- <code title="post /session/{id}/share">client.session.<a href="./src/opencode_ai/resources/session.py">share</a>(id) -> <a href="./src/opencode_ai/types/session.py">Session</a></code>
- <code title="post /session/{id}/summarize">client.session.<a href="./src/opencode_ai/resources/session.py">summarize</a>(id, \*\*<a href="src/opencode_ai/types/session_summarize_params.py">params</a>) -> <a href="./src/opencode_ai/types/session_summarize_response.py">SessionSummarizeResponse</a></code>
- <code title="delete /session/{id}/share">client.session.<a href="./src/opencode_ai/resources/session.py">unshare</a>(id) -> <a href="./src/opencode_ai/types/session.py">Session</a></code>
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_error_codes = True
#
# We also exclude our `tests` as mypy doesn't always infer
# types correctly and Pyright will still catch any type errors.
exclude = ^(src/opencode/_files\.py|_dev/.*\.py|tests/.*)$
exclude = ^(src/opencode_ai/_files\.py|_dev/.*\.py|tests/.*)$

strict_equality = True
implicit_reexport = True
Expand Down
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[project]
name = "opencode"
version = "0.1.0-alpha.1"
name = "opencode-ai"
version = "0.1.0-alpha.2"
description = "The official Python library for the opencode API"
dynamic = ["readme"]
license = "Apache-2.0"
authors = [
{ name = "Opencode", email = "support@sst.dev" },
{ name = "Opencode", email = "hello@sst.dev" },
]
dependencies = [
"httpx>=0.23.0, <1",
Expand Down Expand Up @@ -78,14 +78,14 @@ format = { chain = [
"check:ruff" = "ruff check ."
"fix:ruff" = "ruff check --fix ."

"check:importable" = "python -c 'import opencode'"
"check:importable" = "python -c 'import opencode_ai'"

typecheck = { chain = [
"typecheck:pyright",
"typecheck:mypy"
]}
"typecheck:pyright" = "pyright"
"typecheck:verify-types" = "pyright --verifytypes opencode --ignoreexternal"
"typecheck:verify-types" = "pyright --verifytypes opencode_ai --ignoreexternal"
"typecheck:mypy" = "mypy ."

[build-system]
Expand All @@ -98,7 +98,7 @@ include = [
]

[tool.hatch.build.targets.wheel]
packages = ["src/opencode"]
packages = ["src/opencode_ai"]

[tool.hatch.build.targets.sdist]
# Basically everything except hidden files/directories (such as .github, .devcontainers, .python-version, etc)
Expand Down Expand Up @@ -201,7 +201,7 @@ length-sort = true
length-sort-straight = true
combine-as-imports = true
extra-standard-library = ["typing_extensions"]
known-first-party = ["opencode", "tests"]
known-first-party = ["opencode_ai", "tests"]

[tool.ruff.lint.per-file-ignores]
"bin/**.py" = ["T201", "T203"]
Expand Down
2 changes: 1 addition & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@
],
"release-type": "python",
"extra-files": [
"src/opencode/_version.py"
"src/opencode_ai/_version.py"
]
}
Loading