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

Method __init__

src/opencode_ai/_client.py:58–107  ·  view source on GitHub ↗

Construct a new synchronous Opencode client instance.

(
        self,
        *,
        base_url: str | httpx.URL | None = None,
        timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
        max_retries: int = DEFAULT_MAX_RETRIES,
        default_headers: Mapping[str, str] | None = None,
        default_query: Mapping[str, object] | None = None,
        # Configure a custom httpx client.
        # We provide a `DefaultHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
        # See the [httpx documentation](https://www.python-httpx.org/api/#client) for more details.
        http_client: httpx.Client | None = None,
        # Enable or disable schema validation for data returned by the API.
        # When enabled an error APIResponseValidationError is raised
        # if the API responds with invalid data for the expected schema.
        #
        # This parameter may be removed or changed in the future.
        # If you rely on this feature, please open a GitHub issue
        # outlining your use-case to help us decide if it should be
        # part of our public interface in the future.
        _strict_response_validation: bool = False,
    )

Source from the content-addressed store, hash-verified

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)
103 self.config = config.ConfigResource(self)
104 self.session = session.SessionResource(self)
105 self.tui = tui.TuiResource(self)
106 self.with_raw_response = OpencodeWithRawResponse(self)
107 self.with_streaming_response = OpencodeWithStreamedResponse(self)
108
109 @property
110 @override

Callers 1

__init__Method · 0.45

Calls 3

getMethod · 0.45

Tested by

no test coverage detected