API Keys#

class ApiKeysClient(*, sdk_config: SDKConfiguration, generated_client: ApiClient)[source]#

Bases: object

Client for managing Arize API keys.

This class is primarily intended for internal use within the SDK. Users are highly encouraged to access resource-specific functionality via arize.ArizeClient.

The API keys client is a thin wrapper around the generated REST API client, using the shared generated API client owned by arize.config.SDKConfiguration.

Parameters:
  • sdk_config (SDKConfiguration) – Resolved SDK configuration.

  • generated_client (ApiClient) – Shared generated API client instance.

list(*, key_type: str | None = None, status: ApiKeyStatus | None = None, limit: int = 50, cursor: str | None = None) ApiKeysList200Response[source]#

List API keys for the authenticated user.

This endpoint supports cursor-based pagination. Optionally filter by key_type ("user" or "service") and status ("active" or "deleted").

Parameters:
  • key_type (str | None) – Optional key type filter ("user" or "service").

  • status (ApiKeyStatus | None) – Optional status filter ("active" or "deleted"). Defaults to "active" on the server side when omitted.

  • limit (int) – Maximum number of keys to return (1 to 100). Defaults to 50.

  • cursor (str | None) – Opaque pagination cursor from a previous response.

Returns:

A paginated API key list response from the Arize REST API.

Raises:

ApiException – If the API request fails.

Return type:

ApiKeysList200Response

create(*, name: str, description: str | None = None, key_type: Literal['user', 'service'] = 'user', expires_at: datetime | None = None, space: str | None = None) ApiKeyCreated[source]#

Create a new API key.

Two key types are supported:

  • "user": authenticates as the creating user with their full permissions. space must not be set.

  • "service": scoped to a specific space, backed by a dedicated bot user with limited roles. space is required.

The returned ApiKeyCreated object contains the full raw key value in its key field. This is the only time the raw key is returned. Store it securely.

Parameters:
  • name (str) – User-defined name for the API key (max 256 characters).

  • description (str | None) – Optional description (max 1000 characters).

  • key_type (Literal['user', 'service']) – Type of key to create — "user" (default) or "service".

  • expires_at (datetime | None) – Optional expiration timestamp. If omitted the key never expires. Must be a future timestamp.

  • space (str | None) – Space name or ID the service key is scoped to. Required when key_type is "service"; must not be set for user keys.

Returns:

The created API key, including the one-time raw key value.

Raises:

ApiException – If the API request fails (e.g. invalid parameters or insufficient permissions).

Return type:

ApiKeyCreated

delete(*, api_key_id: str) None[source]#

Delete an API key.

The key is deactivated immediately and permanently. This operation is irreversible — the key will stop working right away.

Parameters:

api_key_id (str) – ID of the API key to delete.

Returns:

None

Raises:

ApiException – If the API request fails (e.g. key not found or insufficient permissions).

Return type:

None

refresh(*, api_key_id: str, expires_at: datetime | None = None) ApiKeyCreated[source]#

Refresh an existing API key.

Atomically revokes the old key and issues a replacement with the same name, description, type, and scope. The new raw key value is returned in the key field of the response. This is the only time the new raw key is returned. Store it securely.

Parameters:
  • api_key_id (str) – ID of the API key to refresh.

  • expires_at (datetime | None) – New expiration for the replacement key. If omitted the replacement key will not expire.

Returns:

The newly issued API key, including the one-time raw key value.

Raises:

ApiException – If the API request fails (e.g. key not found, already deleted, or insufficient permissions).

Return type:

ApiKeyCreated

Response Types#

class ApiKeyCreated(*, id: Annotated[str, Strict(strict=True)], name: Annotated[str, Strict(strict=True)], description: Annotated[str, Strict(strict=True)] | None = None, key_type: Annotated[str, Strict(strict=True)], status: ApiKeyStatus, redacted_key: Annotated[str, Strict(strict=True)], created_at: datetime, expires_at: datetime | None = None, created_by_user_id: Annotated[str, Strict(strict=True)], key: Annotated[str, Strict(strict=True)])[source]#

Bases: BaseModel

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:
id: StrictStr#
name: StrictStr#
description: StrictStr | None#
key_type: StrictStr#
status: ApiKeyStatus#
redacted_key: StrictStr#
created_at: datetime#
expires_at: datetime | None#
created_by_user_id: StrictStr#
key: StrictStr#
classmethod key_type_validate_enum(value)[source]#

Validates the enum

model_config: ClassVar[ConfigDict] = {'populate_by_name': True, 'protected_namespaces': (), 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

to_str() str[source]#

Returns the string representation of the model using alias

Return type:

str

to_json() str[source]#

Returns the JSON representation of the model using alias

Return type:

str

classmethod from_json(json_str: str) Self | None[source]#

Create an instance of ApiKeyCreated from a JSON string

Parameters:

json_str (str)

Return type:

Self | None

to_dict() Dict[str, Any][source]#

Return the dictionary representation of the model using alias.

This has the following differences from calling pydantic’s self.model_dump(by_alias=True):

  • None is only added to the output dict for nullable fields that were set at model initialization. Other fields with value None are ignored.

Return type:

Dict[str, Any]

classmethod from_dict(obj: Dict[str, Any] | None) Self | None[source]#

Create an instance of ApiKeyCreated from a dict

Parameters:

obj (Dict[str, Any] | None)

Return type:

Self | None

class ApiKeyStatus(value, names=_not_given, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: str, Enum

Current status of the API key. - active - The key is valid for use. - deleted - The key has been deleted by a user.

ACTIVE = 'active'#
DELETED = 'deleted'#
classmethod from_json(json_str: str) Self[source]#

Create an instance of ApiKeyStatus from a JSON string

Parameters:

json_str (str)

Return type:

Self

class ApiKeysList200Response(*, api_keys: List[ApiKey], pagination: PaginationMetadata)[source]#

Bases: BaseModel

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:
  • api_keys (List[ApiKey])

  • pagination (PaginationMetadata)

api_keys: List[ApiKey]#
pagination: PaginationMetadata#
model_config: ClassVar[ConfigDict] = {'populate_by_name': True, 'protected_namespaces': (), 'validate_assignment': True, 'validate_by_alias': True, 'validate_by_name': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

to_str() str[source]#

Returns the string representation of the model using alias

Return type:

str

to_json() str[source]#

Returns the JSON representation of the model using alias

Return type:

str

classmethod from_json(json_str: str) Self | None[source]#

Create an instance of ApiKeysList200Response from a JSON string

Parameters:

json_str (str)

Return type:

Self | None

to_dict() Dict[str, Any][source]#

Return the dictionary representation of the model using alias.

This has the following differences from calling pydantic’s self.model_dump(by_alias=True):

  • None is only added to the output dict for nullable fields that were set at model initialization. Other fields with value None are ignored.

Return type:

Dict[str, Any]

classmethod from_dict(obj: Dict[str, Any] | None) Self | None[source]#

Create an instance of ApiKeysList200Response from a dict

Parameters:

obj (Dict[str, Any] | None)

Return type:

Self | None

to_df(by_alias: bool = False, exclude_none: str | bool = True, json_normalize: bool = False, convert_dtypes: bool = True, expand_field: str = 'additional_properties', expand_prefix: str = '') pd.DataFrame#

Convert a list of objects to a pandas.DataFrame.

Behavior:
  • If an item is a Pydantic v2 model, use .model_dump(by_alias=…).

  • If an item is a mapping (dict-like), use it as-is.

  • Otherwise, raise a ValueError (unsupported row type).

Parameters:
  • self (object) – The object instance containing the field to convert.

  • by_alias (bool) – Use field aliases when dumping Pydantic models.

  • exclude_none (str | bool) – Control None/NaN column dropping. - False: keep Nones as-is - “all”: drop columns where all values are None/NaN - “any”: drop columns where any value is None/NaN - True: alias for “all”

  • json_normalize (bool) – If True, flatten nested dicts via pandas.json_normalize.

  • convert_dtypes (bool) – If True, call DataFrame.convert_dtypes() at the end.

  • expand_field (str) – If set, look for this field in each row and

  • columns. (expand its keys into top-level)

  • expand_prefix (str) – If set, prefix expanded column names with this string.

Returns:

The converted DataFrame.

Return type:

pandas.DataFrame