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

Method create_async

src/openrouter/byok.py:518–683  ·  view source on GitHub ↗

r"""Create a BYOK provider credential Create a new bring-your-own-key (BYOK) provider credential. The raw key is encrypted at rest and never returned in API responses. Defaults to the authenticated entity's default workspace; use the `workspace_id` body field to scope to a different workspa

(
        self,
        *,
        key: str,
        provider: components.BYOKProviderSlug,
        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,
        name: OptionalNullable[str] = UNSET,
        workspace_id: Optional[str] = None,
        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

516 raise errors.OpenRouterDefaultError("Unexpected response received", http_res)
517
518 async def create_async(
519 self,
520 *,
521 key: str,
522 provider: components.BYOKProviderSlug,
523 http_referer: Optional[str] = None,
524 x_open_router_title: Optional[str] = None,
525 x_open_router_categories: Optional[str] = None,
526 allowed_models: OptionalNullable[Iterable[str]] = UNSET,
527 allowed_user_ids: OptionalNullable[Iterable[str]] = UNSET,
528 disabled: Optional[bool] = None,
529 is_fallback: Optional[bool] = None,
530 name: OptionalNullable[str] = UNSET,
531 workspace_id: Optional[str] = None,
532 retries: OptionalNullable[utils.RetryConfig] = UNSET,
533 server_url: Optional[str] = None,
534 timeout_ms: Optional[int] = None,
535 http_headers: Optional[Mapping[str, str]] = None,
536 ) -> components.CreateBYOKKeyResponse:
537 r"""Create a BYOK provider credential
538
539 Create a new bring-your-own-key (BYOK) provider credential. The raw key is encrypted at rest and never returned in API responses. Defaults to the authenticated entity's default workspace; use the `workspace_id` body field to scope to a different workspace. Treat the raw key as write-only; it is never returned after creation. [Management key](/docs/guides/overview/auth/management-api-keys) required.
540
541 :param key: The raw provider API key or credential. This value is encrypted at rest and never returned in API responses.
542 :param provider: The upstream provider this credential authenticates against, as a lowercase slug (e.g. `openai`, `anthropic`, `amazon-bedrock`).
543 :param http_referer: The app identifier should be your app's URL and is used as the primary identifier for rankings.
544 This is used to track API usage per application.
545
546 :param x_open_router_title: The app display name allows you to customize how your app appears in OpenRouter's dashboard.
547
548 :param x_open_router_categories: Comma-separated list of app categories (e.g. \"cli-agent,cloud-agent\"). Used for marketplace rankings.
549
550 :param allowed_models: Optional allowlist of model slugs this credential may be used for. `null` means no restriction.
551 :param allowed_user_ids: Optional allowlist of user IDs that may use this credential. `null` means no restriction.
552 :param disabled: Whether this credential should be created in a disabled state.
553 :param is_fallback: Whether this credential is treated as a fallback — used only after non-fallback keys for the same provider have been tried.
554 :param name: Optional human-readable name for the credential.
555 :param workspace_id: Optional workspace ID. Defaults to the authenticated entity's default workspace.
556 :param retries: Override the default retry configuration for this method
557 :param server_url: Override the default server URL for this method
558 :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
559 :param http_headers: Additional headers to set or replace on requests.
560 """
561 base_url = None
562 url_variables = None
563 if timeout_ms is None:
564 timeout_ms = self.sdk_configuration.timeout_ms
565
566 if server_url is not None:
567 base_url = server_url
568 else:
569 base_url = self._get_url(base_url, url_variables)
570
571 request = operations.CreateBYOKKeyRequest(
572 http_referer=http_referer,
573 x_open_router_title=x_open_router_title,
574 x_open_router_categories=x_open_router_categories,
575 create_byok_key_request=components.CreateBYOKKeyRequest(

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_request_asyncMethod · 0.80
do_request_asyncMethod · 0.80

Tested by

no test coverage detected