Api Keys (v1)
Reference for magick_mind.resources.v1.api_keys.
magick_mind.resources.v1.api_keys
API Keys resource for Magick Mind SDK v1 API.
Provides methods for managing API keys for authenticated requests.
ApiKeysResourceV1
class ApiKeysResourceV1(BaseResource)Resource client for API key operations.
ApiKeysResourceV1.create
async def create(user_id: str,
project_id: str,
models: list[str],
key_alias: str,
duration: Optional[str] = None,
team_id: Optional[str] = None,
max_budget: Optional[float] = None) -> CreateApiKeyResponseCreate a new API key.
Arguments:
user_id- User ID that owns this keyproject_id- Project ID to associate withmodels- List of allowed model nameskey_alias- Human-readable key nameduration- Optional validity duration (e.g., '30d', '1y')team_id- Optional team IDmax_budget- Optional spending limit
Returns:
CreateApiKeyResponse with the new API key
Raises:
ProblemDetailsException- If the request fails
Example:
response = await client.v1.api_keys.create( ... user_id="user-123", ... project_id="proj-456", ... models=["gpt-4", "gpt-3.5-turbo"], ... key_alias="Production Key", ... duration="90d", ... max_budget=100.0 ... ) print(f"API Key: {response.key.key}")
ApiKeysResourceV1.list
async def list(user_id: str) -> ListApiKeysResponseList all API keys for a user.
Arguments:
user_id- User ID to list keys for
Returns:
ListApiKeysResponse with list of API keys
Raises:
ProblemDetailsException- If the request fails
Example:
response = await client.v1.api_keys.list(user_id="user-123") for key in response.keys: ... print(f"{key.key_alias}: {key.key_id}")
ApiKeysResourceV1.update
async def update(key: str,
models: list[str],
key_alias: str,
duration: Optional[str] = None,
max_budget: Optional[float] = None) -> UpdateApiKeyResponseUpdate an existing API key.
Arguments:
key- The API key to updatemodels- Updated list of allowed modelskey_alias- Updated key alias/nameduration- Optional updated validity durationmax_budget- Optional updated spending limit
Returns:
UpdateApiKeyResponse with updated key details
Raises:
ProblemDetailsException- If the request fails
Example:
response = await client.v1.api_keys.update( ... key="sk-...", ... models=["gpt-4", "claude-3"], ... key_alias="Updated Production Key", ... max_budget=200.0 ... )
ApiKeysResourceV1.delete
async def delete(key_id: str) -> DeleteApiKeyResponseDelete an API key.
Arguments:
key_id- The key ID to delete
Returns:
DeleteApiKeyResponse with confirmation
Raises:
ProblemDetailsException- If the request fails
Example:
response = await client.v1.api_keys.delete(key_id="key-abc-123") print(response.message)