Creating a secret profile¶
profile = client.secret_profile.create(
name="openai-prod",
secret="sk-...",
provider="openai",
description="Production key for the chat model.",
)
One call stores the secret encrypted on the platform and returns the profile.
Keep profile.profile_id; that is what later stages ask for.
Parameters¶
Parameter |
Type |
Meaning |
|---|---|---|
|
|
Human-readable name. Letters, digits, spaces, underscores and hyphens, 1 to 63 characters. |
|
|
The secret to store, for example an API key. Not empty, at most 4096 characters. |
|
|
Which provider the secret belongs to, for example |
|
|
Free text, at most 1024 characters. Keyword-only. |
|
|
Category of the profile. Keyword-only. Defaults to |
The name and the secret are validated by the platform, not by the SDK, so a rejected value surfaces as one of the errors below rather than before the call.
Return value¶
A Profile. See Secret profiles for the
attribute descriptions. secret_data holds an obfuscated copy of the secret,
never the secret itself.
Errors¶
InvalidSecretNameErrorThe name was rejected: it is empty, too long, or contains characters outside letters, digits, spaces, underscores and hyphens.
InvalidSecretValueErrorThe secret was rejected: it is empty, whitespace only, or longer than 4096 characters. The message does not contain the secret.
Any other failure surfaces as one of the general SDK exceptions described in Errors.
Example¶
from arango_ai_sdk.exceptions import InvalidSecretNameError, InvalidSecretValueError
try:
profile = client.secret_profile.create(
name="openai prod!", secret="sk-...", provider="openai"
)
except InvalidSecretNameError as exc:
print(f"Choose another name: {exc}")
except InvalidSecretValueError as exc:
print(f"Check the key: {exc}")
else:
print(f"Stored as {profile.profile_id}")