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

Method __init__

src/opencode_ai/_client.py:219–268  ·  view source on GitHub ↗

Construct a new async AsyncOpencode 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 `DefaultAsyncHttpxClient` 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/#asyncclient) for more details.
        http_client: httpx.AsyncClient | 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

217 # client options
218
219 def __init__(
220 self,
221 *,
222 base_url: str | httpx.URL | None = None,
223 timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
224 max_retries: int = DEFAULT_MAX_RETRIES,
225 default_headers: Mapping[str, str] | None = None,
226 default_query: Mapping[str, object] | None = None,
227 # Configure a custom httpx client.
228 # We provide a `DefaultAsyncHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`.
229 # See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details.
230 http_client: httpx.AsyncClient | None = None,
231 # Enable or disable schema validation for data returned by the API.
232 # When enabled an error APIResponseValidationError is raised
233 # if the API responds with invalid data for the expected schema.
234 #
235 # This parameter may be removed or changed in the future.
236 # If you rely on this feature, please open a GitHub issue
237 # outlining your use-case to help us decide if it should be
238 # part of our public interface in the future.
239 _strict_response_validation: bool = False,
240 ) -> None:
241 """Construct a new async AsyncOpencode client instance."""
242 if base_url is None:
243 base_url = os.environ.get("OPENCODE_BASE_URL")
244 if base_url is None:
245 base_url = f"http://localhost:54321"
246
247 super().__init__(
248 version=__version__,
249 base_url=base_url,
250 max_retries=max_retries,
251 timeout=timeout,
252 http_client=http_client,
253 custom_headers=default_headers,
254 custom_query=default_query,
255 _strict_response_validation=_strict_response_validation,
256 )
257
258 self._default_stream_cls = AsyncStream
259
260 self.event = event.AsyncEventResource(self)
261 self.app = app.AsyncAppResource(self)
262 self.find = find.AsyncFindResource(self)
263 self.file = file.AsyncFileResource(self)
264 self.config = config.AsyncConfigResource(self)
265 self.session = session.AsyncSessionResource(self)
266 self.tui = tui.AsyncTuiResource(self)
267 self.with_raw_response = AsyncOpencodeWithRawResponse(self)
268 self.with_streaming_response = AsyncOpencodeWithStreamedResponse(self)
269
270 @property
271 @override

Callers

nothing calls this directly

Calls 4

getMethod · 0.45
__init__Method · 0.45

Tested by

no test coverage detected