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

name

str

Human-readable name. Letters, digits, spaces, underscores and hyphens, 1 to 63 characters.

secret

str

The secret to store, for example an API key. Not empty, at most 4096 characters.

provider

str, optional

Which provider the secret belongs to, for example "openai". Keyword-only. Recommended, so later stages can pick the right profile.

description

str, optional

Free text, at most 1024 characters. Keyword-only.

profile_type

ProfileType, optional

Category of the profile. Keyword-only. Defaults to ProfileType.LLM, which is what AutoGraph expects for chat and embedding keys.

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

InvalidSecretNameError

The name was rejected: it is empty, too long, or contains characters outside letters, digits, spaces, underscores and hyphens.

InvalidSecretValueError

The 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}")