MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / Opencode

Class Opencode

src/opencode_ai/_client.py:45–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44
45class Opencode(SyncAPIClient):
46 event: event.EventResource
47 app: app.AppResource
48 find: find.FindResource
49 file: file.FileResource
50 config: config.ConfigResource
51 session: session.SessionResource
52 tui: tui.TuiResource
53 with_raw_response: OpencodeWithRawResponse
54 with_streaming_response: OpencodeWithStreamedResponse
55
56 # client options
57
58 def __init__(
59 self,
60 *,
61 base_url: str | httpx.URL | None = None,
62 timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
63 max_retries: int = DEFAULT_MAX_RETRIES,
64 default_headers: Mapping[str, str] | None = None,
65 default_query: Mapping[str, object] | None = None,
66 # Configure a custom httpx client.
67 # We provide a `DefaultHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
68 # See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
69 http_client: httpx.Client | None = None,
70 # Enable or disable schema validation for data returned by the API.
71 # When enabled an error APIResponseValidationError is raised
72 # if the API responds with invalid data for the expected schema.
73 #
74 # This parameter may be removed or changed in the future.
75 # If you rely on this feature, please open a GitHub issue
76 # outlining your use-case to help us decide if it should be
77 # part of our public interface in the future.
78 _strict_response_validation: bool = False,
79 ) -> None:
80 """Construct a new synchronous Opencode client instance."""
81 if base_url is None:
82 base_url = os.environ.get("OPENCODE_BASE_URL")
83 if base_url is None:
84 base_url = f"http://localhost:54321"
85
86 super().__init__(
87 version=__version__,
88 base_url=base_url,
89 max_retries=max_retries,
90 timeout=timeout,
91 http_client=http_client,
92 custom_headers=default_headers,
93 custom_query=default_query,
94 _strict_response_validation=_strict_response_validation,
95 )
96
97 self._default_stream_cls = Stream
98
99 self.event = event.EventResource(self)
100 self.app = app.AppResource(self)
101 self.find = find.FindResource(self)
102 self.file = file.FileResource(self)

Calls

no outgoing calls