Skip to content
Get started

Create a new AI provider key

POST/v1/workspaces/{workspaceId}/ai_provider_keys

Creates a new customer-provided AI provider key in the workspace

Path ParametersExpand Collapse
workspaceId: string
Body ParametersJSONExpand Collapse
metadata: CreateResourceMetadata { name, bundleKey, externalId, labels }

CreateResourceMetadata contains the user-provided fields for creating a workspace-scoped resource. Read-only fields (id, account_id, workspace_id, profile_id, created_at) are excluded since they are set by the server.

name: string

Human-readable name for the resource (e.g., “Customer Support Agent”, “Email Tool”)

bundleKey: optional string

Optional bundle ownership key. See ResourceMetadata.bundle_key.

externalId: optional string

External ID for the resource (e.g., a workflow ID from an external system)

labels: optional map[string]

Arbitrary key-value pairs for categorization and filtering Examples: {“environment”: “production”, “team”: “platform”, “version”: “v2”}

spec: AIProviderKeySpec { apiKey, openrouter, provider }
apiKey: optional string

The provider credential. Accepted on create/update; never populated in responses (the server returns an empty value to avoid leaking it).

openrouter: optional unknown

OpenRouterConfig holds OpenRouter-specific settings. Empty for now; it exists as the oneof seam so provider-specific options (region, base URL, etc.) can be added later without restructuring the spec.

provider: optional "AI_PROVIDER_UNSPECIFIED" or "AI_PROVIDER_OPENROUTER"

The AI provider this key authenticates against.

formatenum
One of the following:
"AI_PROVIDER_UNSPECIFIED"
"AI_PROVIDER_OPENROUTER"
ReturnsExpand Collapse
AIProviderKey object { metadata, spec, info }

AIProviderKey is a credential for an AI provider, scoped to a workspace. Most keys are customer-provided (BYOK); Cadenya also provisions promotional keys (see AIProviderKeyInfo.is_promotional), which cannot be modified or deleted by account administrators. The secret value is never returned in responses.

metadata: ResourceMetadata { id, accountId, createdAt, 7 more }

Standard metadata for persistent, named resources (e.g., agents, tools, prompts)

id: string

Unique identifier for the resource (prefixed ULID, e.g., “agent_01HXK…”)

accountId: string

Account this resource belongs to for multi-tenant isolation (prefixed ULID)

createdAt: string

Timestamp when this resource was created

formatdate-time
name: string

Human-readable name for the resource (e.g., “Customer Support Agent”, “Email Tool”) Required for resources that users interact with directly

profileId: string

ID of the actor (user or service account) that created this resource

workspaceId: string

Workspace this resource belongs to for organizational grouping (prefixed ULID)

bundleKey: optional string

Optional bundle ownership key. When set, indicates the resource is managed by a configuration bundle identified by this key. Used by BulkWorkspaceResources.Apply to track which resources belong to which bundle for reconciliation / soft-delete on re-apply.

externalId: optional string

External ID for the resource (e.g., a workflow ID from an external system)

labels: optional map[string]

Arbitrary key-value pairs for categorization and filtering Examples: {“environment”: “production”, “team”: “platform”, “version”: “v2”}

updatedAt: optional string

Timestamp when this resource was last updated

formatdate-time
spec: AIProviderKeySpec { apiKey, openrouter, provider }
apiKey: optional string

The provider credential. Accepted on create/update; never populated in responses (the server returns an empty value to avoid leaking it).

openrouter: optional unknown

OpenRouterConfig holds OpenRouter-specific settings. Empty for now; it exists as the oneof seam so provider-specific options (region, base URL, etc.) can be added later without restructuring the spec.

provider: optional "AI_PROVIDER_UNSPECIFIED" or "AI_PROVIDER_OPENROUTER"

The AI provider this key authenticates against.

formatenum
One of the following:
"AI_PROVIDER_UNSPECIFIED"
"AI_PROVIDER_OPENROUTER"
info: optional object { disabledModelCount, enabledModelCount, isPromotional }

AIProviderKeyInfo carries server-derived, read-only details about a key, for AI provider management UIs.

disabledModelCount: optional number

Number of disabled models provisioned on this key.

formatint32
enabledModelCount: optional number

Number of enabled models provisioned on this key.

formatint32
isPromotional: optional boolean

Cadenya includes promotional keys (one for onboarding, and potentially more in the future). These are not added or maintained by account administrators.

Create a new AI provider key

curl https://api.cadenya.com/v1/workspaces/$WORKSPACE_ID/ai_provider_keys \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $CADENYA_API_KEY" \
    -d '{
          "metadata": {
            "name": "name"
          },
          "spec": {}
        }'
{
  "metadata": {
    "id": "id",
    "accountId": "accountId",
    "createdAt": "2019-12-27T18:11:19.117Z",
    "name": "name",
    "profileId": "profileId",
    "workspaceId": "workspaceId",
    "bundleKey": "bundleKey",
    "externalId": "externalId",
    "labels": {
      "foo": "string"
    },
    "updatedAt": "2019-12-27T18:11:19.117Z"
  },
  "spec": {
    "apiKey": "apiKey",
    "openrouter": {},
    "provider": "AI_PROVIDER_UNSPECIFIED"
  },
  "info": {
    "disabledModelCount": 0,
    "enabledModelCount": 0,
    "isPromotional": true
  }
}
Returns Examples
{
  "metadata": {
    "id": "id",
    "accountId": "accountId",
    "createdAt": "2019-12-27T18:11:19.117Z",
    "name": "name",
    "profileId": "profileId",
    "workspaceId": "workspaceId",
    "bundleKey": "bundleKey",
    "externalId": "externalId",
    "labels": {
      "foo": "string"
    },
    "updatedAt": "2019-12-27T18:11:19.117Z"
  },
  "spec": {
    "apiKey": "apiKey",
    "openrouter": {},
    "provider": "AI_PROVIDER_UNSPECIFIED"
  },
  "info": {
    "disabledModelCount": 0,
    "enabledModelCount": 0,
    "isPromotional": true
  }
}