AiCredentialPutV2 ai.credential-put@2

Generated at from openvibe-contracts v0.454.0 and openvibe-sdk v0.193.0.

Version
2.0.0
Owner
ai
Visibility
first-party
Status
active
Compatibility
backward
Schema
https://openvibe.network/contracts/ai/credential-put.v2.json

ai.credential-put@2 (OpenVibe.AI; Codes C3): one person's own provider key per provider, stored by the service that holds their consent, PUT /api/v1/credentials/{subject}/{provider} with capability ai.credential.manage. It adds the provider dimension to ai.credential-put@1: a person may keep an Anthropic, OpenAI, DeepSeek, MiniMax, OpenRouter or custom key side by side, each with its own daily budget, and the route without a provider still stores the default one. `key` is the secret (v1's `api_key` stays accepted); `base_url` names the endpoint of a custom provider and is optional elsewhere. OpenVibe.AI encrypts the key at rest, bound to its owner, subject and provider, and never returns it. Provider `node` is unchanged: the person's own machine, named by `machine`, with no key.

Fields

FieldTypeRequiredDescriptionConstraints
providerenumyesanthropic = Anthropic's Messages API; openai = any OpenAI-compatible endpoint; deepseek, minimax and openrouter = those providers; custom = the endpoint in base_url (a URL that speaks the OpenAI or the Anthropic format, by the route it is used on); node = the person's own machine (no key, no base_url, no cost).
  • one of "anthropic", "openai", "deepseek", "minimax", "openrouter", "custom", "link"
keystringThe provider key (ai.credential-put@2's name for v1's api_key). Required the first time, and whenever provider or base_url changes (a key is never sent to a new endpoint without being entered again); otherwise the stored key is kept, and it is never returned.
  • minLength 8
  • maxLength 400
api_keystringThe ai.credential-put@1 name for `key`, still accepted. When both are sent, `key` wins.
  • minLength 8
  • maxLength 400
base_urlstringThe endpoint of a custom provider (required for it): https, no credentials, query or fragment. OpenVibe.AI connects only to public addresses.
  • pattern ^https://[^\s/?#@]+(/[^\s?#]*)?$
  • maxLength 300
machinestringprovider link: the person's own machine (openvibe.link/machines) whose OpenVibe Link runs the model, or `any` of their own.
  • pattern ^(dev_[0-9A-HJKMNP-TV-Z]{26}|any)$
modelsobjectModel per role on this provider; `chat` is the default for the others.
  • no other fields
models.chatstring
  • minLength 1
  • maxLength 120
models.visionstring
  • minLength 1
  • maxLength 120
models.directorstring
  • minLength 1
  • maxLength 120
models.summarystring
  • minLength 1
  • maxLength 120
models.legacystring
  • minLength 1
  • maxLength 120
budget_usd_per_daynumberThe person's own daily cap on estimated spend with this provider's key; 0 or absent = no cap.
  • minimum 0
  • maximum 1000

Examples

From the contract's own test fixtures: valid ones validate, rejected ones must fail.

Valid: custom-base
{
  "provider": "custom",
  "key": "sk-custom-EXAMPLEEXAMPLEEXAMPLE",
  "base_url": "https://llm.example.com/anthropic",
  "budget_usd_per_day": 1
}
Valid: deepseek-key
{
  "provider": "deepseek",
  "key": "sk-deepseek-EXAMPLEEXAMPLEEXAMPLE",
  "models": {
    "chat": "deepseek-chat"
  },
  "budget_usd_per_day": 3
}
Valid: link-any
{
  "provider": "link",
  "machine": "any",
  "models": {
    "chat": "llama3.1:8b"
  }
}
Valid: link
{
  "provider": "link",
  "machine": "dev_01M5YGM39VC2RRGDQPRD6D4SHD",
  "models": {
    "chat": "llama3.1:8b"
  }
}
Valid: minimax-key
{
  "provider": "minimax",
  "key": "sk-minimax-EXAMPLEEXAMPLEEXAMPLE",
  "models": {
    "chat": "MiniMax-M2"
  }
}
Valid: models-only
{
  "provider": "openai",
  "base_url": "https://openrouter.ai/api/v1",
  "models": {
    "chat": "gpt-4o-mini"
  }
}
Valid: openrouter
{
  "provider": "openai",
  "base_url": "https://openrouter.ai/api/v1",
  "api_key": "sk-or-v1-EXAMPLEEXAMPLEEXAMPLE",
  "models": {
    "chat": "gpt-4o-mini"
  },
  "budget_usd_per_day": 2
}
Rejected: custom-http-base
{
  "provider": "custom",
  "key": "sk-custom-EXAMPLEEXAMPLE",
  "base_url": "http://llm.example.com/anthropic"
}
Rejected: custom-without-base
{
  "provider": "custom",
  "key": "sk-custom-EXAMPLEEXAMPLE"
}
Rejected: http-base
{
  "provider": "openai",
  "base_url": "http://10.0.0.1/v1",
  "api_key": "sk-EXAMPLEEXAMPLE"
}
Rejected: link-machine-anyone
{
  "provider": "link",
  "machine": "anyone",
  "models": {
    "chat": "llama3.1:8b"
  }
}
Rejected: link-with-key
{
  "provider": "link",
  "machine": "dev_01M5YGM39VC2RRGDQPRD6D4SHD",
  "api_key": "sk-not-for-a-machine"
}
Rejected: link-without-machine
{
  "provider": "link",
  "models": {
    "chat": "llama3.1:8b"
  }
}
Rejected: unknown-provider
{
  "provider": "groq",
  "key": "sk-groq-EXAMPLEEXAMPLE"
}

Validate

const contracts = require('openvibe-contracts');
contracts.validate('ai.credential-put@2', value);   // { valid, errors: [{ path, message }] }