MCPcopy Create free account
hub / github.com/OpenRouterTeam/python-sdk / update

Method update

src/openrouter/byok.py:1197–1359  ·  view source on GitHub ↗

r"""Update a BYOK provider credential Update an existing bring-your-own-key (BYOK) provider credential by its `id`. Include the `key` field to rotate the raw provider API key in-place (the previous key material is overwritten). [Management key](/docs/guides/overview/auth/management-api-keys

(
        self,
        *,
        id: str,
        http_referer: Optional[str] = None,
        x_open_router_title: Optional[str] = None,
        x_open_router_categories: Optional[str] = None,
        allowed_models: OptionalNullable[Iterable[str]] = UNSET,
        allowed_user_ids: OptionalNullable[Iterable[str]] = UNSET,
        disabled: Optional[bool] = None,
        is_fallback: Optional[bool] = None,
        key: Optional[str] = None,
        name: OptionalNullable[str] = UNSET,
        retries: OptionalNullable[utils.RetryConfig] = UNSET,
        server_url: Optional[str] = None,
        timeout_ms: Optional[int] = None,
        http_headers: Optional[Mapping[str, str]] = None,
    )

Source from the content-addressed store, hash-verified

1195 raise errors.OpenRouterDefaultError("Unexpected response received", http_res)
1196
1197 def update(
1198 self,
1199 *,
1200 id: str,
1201 http_referer: Optional[str] = None,
1202 x_open_router_title: Optional[str] = None,
1203 x_open_router_categories: Optional[str] = None,
1204 allowed_models: OptionalNullable[Iterable[str]] = UNSET,
1205 allowed_user_ids: OptionalNullable[Iterable[str]] = UNSET,
1206 disabled: Optional[bool] = None,
1207 is_fallback: Optional[bool] = None,
1208 key: Optional[str] = None,
1209 name: OptionalNullable[str] = UNSET,
1210 retries: OptionalNullable[utils.RetryConfig] = UNSET,
1211 server_url: Optional[str] = None,
1212 timeout_ms: Optional[int] = None,
1213 http_headers: Optional[Mapping[str, str]] = None,
1214 ) -> components.UpdateBYOKKeyResponse:
1215 r"""Update a BYOK provider credential
1216
1217 Update an existing bring-your-own-key (BYOK) provider credential by its `id`. Include the `key` field to rotate the raw provider API key in-place (the previous key material is overwritten). [Management key](/docs/guides/overview/auth/management-api-keys) required.
1218
1219 :param id: The BYOK credential ID (UUID).
1220 :param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
1221 This is used to track API usage per application.
1222
1223 :param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
1224
1225 :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
1226
1227 :param allowed_models: Optional allowlist of model slugs this credential may be used for. `null` means no restriction.
1228 :param allowed_user_ids: Optional allowlist of user IDs that may use this credential. `null` means no restriction.
1229 :param disabled: Whether this credential is disabled.
1230 :param is_fallback: Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried.
1231 :param key: A new raw provider API key to rotate the credential in-place. The previous key material is overwritten and the masked label is regenerated. Encrypted at rest and never returned in API responses.
1232 :param name: Optional human-readable name for the credential.
1233 :param retries: Override the default retry configuration for this method
1234 :param server_url: Override the default server URL for this method
1235 :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1236 :param http_headers: Additional headers to set or replace on requests.
1237 """
1238 base_url = None
1239 url_variables = None
1240 if timeout_ms is None:
1241 timeout_ms = self.sdk_configuration.timeout_ms
1242
1243 if server_url is not None:
1244 base_url = server_url
1245 else:
1246 base_url = self._get_url(base_url, url_variables)
1247
1248 request = operations.UpdateBYOKKeyRequest(
1249 http_referer=http_referer,
1250 x_open_router_title=x_open_router_title,
1251 x_open_router_categories=x_open_router_categories,
1252 id=id,
1253 update_byok_key_request=components.UpdateBYOKKeyRequest(
1254 allowed_models=utils.unmarshal(

Callers

nothing calls this directly

Calls 6

HookContextClass · 0.90
get_security_from_envFunction · 0.90
unmarshal_json_responseFunction · 0.90
_get_urlMethod · 0.80
_build_requestMethod · 0.80
do_requestMethod · 0.80

Tested by

no test coverage detected