import Cadenya from '@cadenya/cadenya';
const client = new Cadenya({
apiKey: process.env['CADENYA_API_KEY'], // This is the default and can be omitted
});
const aiProviderKey = await client.aiProviderKeys.create({
workspaceId: 'workspace_01HXKD2E5NQM3T9AYWCF133E3Q',
metadata: { name: 'name' },
spec: {},
});
console.log(aiProviderKey.metadata);import os
from cadenya import Cadenya
client = Cadenya(
api_key=os.environ.get("CADENYA_API_KEY"), # This is the default and can be omitted
)
ai_provider_key = client.ai_provider_keys.create(
workspace_id="workspace_01HXKD2E5NQM3T9AYWCF133E3Q",
metadata={
"name": "name"
},
spec={},
)
print(ai_provider_key.metadata)package main
import (
"context"
"fmt"
"go.cadenya.com/cadenya-go"
"go.cadenya.com/cadenya-go/option"
"go.cadenya.com/cadenya-go/shared"
)
func main() {
client := cadenya.NewClient(
option.WithAPIKey("My API Key"),
)
aiProviderKey, err := client.AIProviderKeys.New(context.TODO(), cadenya.AIProviderKeyNewParams{
WorkspaceID: cadenya.String("workspace_01HXKD2E5NQM3T9AYWCF133E3Q"),
Metadata: shared.CreateResourceMetadataParam{
Name: "name",
},
Spec: cadenya.AIProviderKeySpecParam{},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", aiProviderKey.Metadata)
}
require "cadenya"
cadenya = Cadenya::Client.new(api_key: "My API Key")
ai_provider_key = cadenya.ai_provider_keys.create(
workspace_id: "workspace_01HXKD2E5NQM3T9AYWCF133E3Q",
metadata: {name: "name"},
spec: {}
)
puts(ai_provider_key)cadenya ai-provider-keys create \
--api-key 'My API Key' \
--workspace-id workspace_01HXKD2E5NQM3T9AYWCF133E3Q \
--metadata '{name: name}' \
--spec '{}'curl --request POST \
--url https://api.cadenya.com/v1/workspaces/{workspaceId}/ai_provider_keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"metadata": {
"name": "<string>",
"externalId": "<string>",
"labels": {}
},
"spec": {
"credentials": {
"type": "apiKey",
"apiKey": {
"apiKey": "<string>"
}
},
"config": {
"type": "openrouter",
"openrouter": {
"region": "<string>"
}
}
}
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cadenya.com/v1/workspaces/{workspaceId}/ai_provider_keys",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'metadata' => [
'name' => '<string>',
'externalId' => '<string>',
'labels' => [
]
],
'spec' => [
'credentials' => [
'type' => 'apiKey',
'apiKey' => [
'apiKey' => '<string>'
]
],
'config' => [
'type' => 'openrouter',
'openrouter' => [
'region' => '<string>'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.cadenya.com/v1/workspaces/{workspaceId}/ai_provider_keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"metadata\": {\n \"name\": \"<string>\",\n \"externalId\": \"<string>\",\n \"labels\": {}\n },\n \"spec\": {\n \"credentials\": {\n \"type\": \"apiKey\",\n \"apiKey\": {\n \"apiKey\": \"<string>\"\n }\n },\n \"config\": {\n \"type\": \"openrouter\",\n \"openrouter\": {\n \"region\": \"<string>\"\n }\n }\n }\n}")
.asString();{
"metadata": {
"id": "<string>",
"accountId": "account_01HXKD2E5NQM3T9AYWCFTJHJVF",
"workspaceId": "workspace_01HXKD2E5NQM3T9AYWCF133E3Q",
"name": "<string>",
"profileId": "profile_01HXKD2E5NQM3T9AYWCFS0AP08",
"createdAt": "2023-11-07T05:31:56Z",
"externalId": "<string>",
"labels": {},
"updatedAt": "2023-11-07T05:31:56Z"
},
"spec": {
"credentials": {
"type": "apiKey",
"apiKey": {
"apiKey": "<string>"
}
},
"config": {
"type": "openrouter",
"openrouter": {
"region": "<string>"
}
}
},
"info": {
"enabledModelCount": 123,
"disabledModelCount": 123,
"isPromotional": true
}
}{
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}Create a new AI provider key
Creates a new customer-provided AI provider key in the workspace
import Cadenya from '@cadenya/cadenya';
const client = new Cadenya({
apiKey: process.env['CADENYA_API_KEY'], // This is the default and can be omitted
});
const aiProviderKey = await client.aiProviderKeys.create({
workspaceId: 'workspace_01HXKD2E5NQM3T9AYWCF133E3Q',
metadata: { name: 'name' },
spec: {},
});
console.log(aiProviderKey.metadata);import os
from cadenya import Cadenya
client = Cadenya(
api_key=os.environ.get("CADENYA_API_KEY"), # This is the default and can be omitted
)
ai_provider_key = client.ai_provider_keys.create(
workspace_id="workspace_01HXKD2E5NQM3T9AYWCF133E3Q",
metadata={
"name": "name"
},
spec={},
)
print(ai_provider_key.metadata)package main
import (
"context"
"fmt"
"go.cadenya.com/cadenya-go"
"go.cadenya.com/cadenya-go/option"
"go.cadenya.com/cadenya-go/shared"
)
func main() {
client := cadenya.NewClient(
option.WithAPIKey("My API Key"),
)
aiProviderKey, err := client.AIProviderKeys.New(context.TODO(), cadenya.AIProviderKeyNewParams{
WorkspaceID: cadenya.String("workspace_01HXKD2E5NQM3T9AYWCF133E3Q"),
Metadata: shared.CreateResourceMetadataParam{
Name: "name",
},
Spec: cadenya.AIProviderKeySpecParam{},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", aiProviderKey.Metadata)
}
require "cadenya"
cadenya = Cadenya::Client.new(api_key: "My API Key")
ai_provider_key = cadenya.ai_provider_keys.create(
workspace_id: "workspace_01HXKD2E5NQM3T9AYWCF133E3Q",
metadata: {name: "name"},
spec: {}
)
puts(ai_provider_key)cadenya ai-provider-keys create \
--api-key 'My API Key' \
--workspace-id workspace_01HXKD2E5NQM3T9AYWCF133E3Q \
--metadata '{name: name}' \
--spec '{}'curl --request POST \
--url https://api.cadenya.com/v1/workspaces/{workspaceId}/ai_provider_keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"metadata": {
"name": "<string>",
"externalId": "<string>",
"labels": {}
},
"spec": {
"credentials": {
"type": "apiKey",
"apiKey": {
"apiKey": "<string>"
}
},
"config": {
"type": "openrouter",
"openrouter": {
"region": "<string>"
}
}
}
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cadenya.com/v1/workspaces/{workspaceId}/ai_provider_keys",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'metadata' => [
'name' => '<string>',
'externalId' => '<string>',
'labels' => [
]
],
'spec' => [
'credentials' => [
'type' => 'apiKey',
'apiKey' => [
'apiKey' => '<string>'
]
],
'config' => [
'type' => 'openrouter',
'openrouter' => [
'region' => '<string>'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.cadenya.com/v1/workspaces/{workspaceId}/ai_provider_keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"metadata\": {\n \"name\": \"<string>\",\n \"externalId\": \"<string>\",\n \"labels\": {}\n },\n \"spec\": {\n \"credentials\": {\n \"type\": \"apiKey\",\n \"apiKey\": {\n \"apiKey\": \"<string>\"\n }\n },\n \"config\": {\n \"type\": \"openrouter\",\n \"openrouter\": {\n \"region\": \"<string>\"\n }\n }\n }\n}")
.asString();{
"metadata": {
"id": "<string>",
"accountId": "account_01HXKD2E5NQM3T9AYWCFTJHJVF",
"workspaceId": "workspace_01HXKD2E5NQM3T9AYWCF133E3Q",
"name": "<string>",
"profileId": "profile_01HXKD2E5NQM3T9AYWCFS0AP08",
"createdAt": "2023-11-07T05:31:56Z",
"externalId": "<string>",
"labels": {},
"updatedAt": "2023-11-07T05:31:56Z"
},
"spec": {
"credentials": {
"type": "apiKey",
"apiKey": {
"apiKey": "<string>"
}
},
"config": {
"type": "openrouter",
"openrouter": {
"region": "<string>"
}
}
},
"info": {
"enabledModelCount": 123,
"disabledModelCount": 123,
"isPromotional": true
}
}{
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The workspace that will own this key.
"workspace_01HXKD2E5NQM3T9AYWCF133E3Q"
Body
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.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Response
OK
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.
Standard metadata for persistent, named resources (e.g., agents, tools, prompts)
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Server-populated info (e.g. how many models route through this key). Populated on reads when requested; see ListAIProviderKeysRequest.include_info.
Show child attributes
Show child attributes