{"record":{"id":"666088781653b8a6","repo":"openai/openai-python","slug":"the-default-query-and-set-default-query-argume","errorCode":null,"errorMessage":"The `default_query` and `set_default_query` arguments are mutually exclusive","messagePattern":"The `default_query` and `set_default_query` arguments are mutually exclusive","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/_client.py","lineNumber":709,"sourceCode":"        timeout: float | Timeout | None | NotGiven = not_given,\n        http_client: httpx2.Client | None = None,\n        max_retries: int | NotGiven = not_given,\n        default_headers: Mapping[str, str] | None = None,\n        set_default_headers: Mapping[str, str] | None = None,\n        default_query: Mapping[str, object] | None = None,\n        set_default_query: Mapping[str, object] | None = None,\n        _enforce_credentials: bool | None = None,\n        _extra_kwargs: Mapping[str, Any] = {},\n    ) -> Self:\n        \"\"\"\n        Create a new client instance re-using the same options given to the current client with optional overriding.\n        `data_residency` replaces the inherited HTTP and WebSocket endpoints, without changing this client.\n        \"\"\"\n        if default_headers is not None and set_default_headers is not None:\n            raise ValueError(\"The `default_headers` and `set_default_headers` arguments are mutually exclusive\")\n\n        if default_query is not None and set_default_query is not None:\n            raise ValueError(\"The `default_query` and `set_default_query` arguments are mutually exclusive\")\n\n        provider_changed = not isinstance(provider, NotGiven) and provider is not self._provider\n        inherited_organization = None if provider_changed else self.organization\n        inherited_project = None if provider_changed else self.project\n\n        headers: Mapping[str, str] = {} if provider_changed else self._custom_headers\n        if (\n            is_x509_workload_identity(workload_identity)\n            and not is_x509_workload_identity(self.workload_identity)\n            and self._ambient_authorizations\n        ):\n            headers = {\n                name: value\n                for name, value in headers.items()\n                if name.lower() != \"authorization\" or value not in self._ambient_authorizations\n            }\n        if default_headers is not None:\n            if any(name.lower() == \"authorization\" for name in default_headers):","sourceCodeStart":691,"sourceCodeEnd":727,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/_client.py#L691-L727","documentation":"The query-string analogue of the headers conflict: `copy(default_query=...)` merges query params while `copy(set_default_query=...)` replaces them; supplying both is rejected with ValueError.","triggerScenarios":"`client.copy(default_query={'api-version': 'x'}, set_default_query={'foo': 'bar'})`; generic client-derivation helpers forwarding both.","commonSituations":"Multi-tenant gateways adding per-tenant query params on top of defaults; refactors between merge and replace semantics.","solutions":["Use only `set_default_query` to fully control the query, or only `default_query` to add on top of inherited params","Normalize kwargs in wrapper code so both never appear together"],"exampleFix":"# before\nnew = client.copy(default_query={'a': 1}, set_default_query={'b': 2})\n\n# after\nnew = client.copy(set_default_query={'a': 1, 'b': 2})","handlingStrategy":"validation","validationCode":"assert not (default_query is not None and set_default_query is not None), \\\n    'copy(): default_query XOR set_default_query'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Compute the final query dict once and pass only set_default_query","Document merge-vs-replace semantics wherever you expose client.copy wrappers"],"tags":["query-params","copy","configuration","conflict","valueerror"],"backgroundTag":"conflicting-constructor-arguments","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}