---
title: "ai.credential@2 · OpenVibe.Services"
canonical: "https://openvibe.services/docs/contracts/ai.credential"
updated: null
---

# ai.credential@2 · OpenVibe.Services

HTML: [ai.credential@2 · OpenVibe.Services](https://openvibe.services/docs/contracts/ai.credential)

# AiCredentialV2 `ai.credential@2`

Generated at 2026-12-01 05:42:00 UTC from [`openvibe-contracts v0.454.0`](https://github.com/OpenVibers/OpenVibe.Contracts/tree/v0.454.0) and [`openvibe-sdk v0.193.0`](https://github.com/OpenVibers/OpenVibe.SDK/tree/v0.193.0).

- Version: 2.0.0
- Owner: ai
- Visibility: first-party
- Status: active
- Compatibility: backward
- Schema: [`https://openvibe.network/contracts/ai/credential.v2.json`](/docs/contracts/ai.credential.json)

ai.credential@2 (OpenVibe.AI; Codes C3): one stored credential as its owner service reads it (GET or PUT /api/v1/credentials/{subject} or /{subject}/{provider}): never the key, only its last four characters. It widens ai.credential@1's provider to the providers of ai.credential-put@2, so a person may keep one key per provider; \`key\_hint\` is present for every provider except \`node\`, whose machine is named instead.

## Fields

| Field | Type | Required | Description | Constraints |
| --- | --- | --- | --- | --- |
| `subject` | string | yes |  | - `pattern ^usr_[0-9A-HJKMNP-TV-Z]{26}$` |
| `owner` | string | yes | The service that stored it; only it may use or change it. | - `pattern ^[a-z][a-z0-9-]{1,31}$` |
| `provider` | enum | yes |  | - `one of "anthropic", "openai", "deepseek", "minimax", "openrouter", "custom", "link"` |
| `machine` | string \| null |  | provider link: the machine it runs on, or \`any\` of the person's own | - `pattern ^(dev_[0-9A-HJKMNP-TV-Z]{26}\|any)$` |
| `base_url` | string \| null |  |  | - `maxLength 300` |
| `key_hint` | string |  |  | - `pattern ^…[\s\S]{1,4}$` |
| `models` | object |  | Model per role on this provider; \`chat\` is the default for the others. | - `no other fields` |
| `models.chat` | string |  |  | - `minLength 1`<br>- `maxLength 120` |
| `models.vision` | string |  |  | - `minLength 1`<br>- `maxLength 120` |
| `models.director` | string |  |  | - `minLength 1`<br>- `maxLength 120` |
| `models.summary` | string |  |  | - `minLength 1`<br>- `maxLength 120` |
| `models.legacy` | string |  |  | - `minLength 1`<br>- `maxLength 120` |
| `budget_usd_per_day` | number \| null |  |  | - `minimum 0` |
| `spent_usd_today` | number |  |  | - `minimum 0` |
| `created_at` | string | yes |  | - `format date-time` |
| `updated_at` | string | yes |  | - `format date-time` |
| `last_used_at` | string \| null |  |  | - `format date-time` |

## Examples

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

 Valid: custom

~~~~
{
  "subject": "usr_01JAB2C3D4E5F6G7H8J9K0MNPQ",
  "owner": "codes",
  "provider": "custom",
  "base_url": "https://llm.example.com/anthropic",
  "key_hint": "…MPLE",
  "models": {},
  "budget_usd_per_day": null,
  "spent_usd_today": 0,
  "created_at": "2026-10-30T00:00:00.000Z",
  "updated_at": "2026-10-30T00:00:00.000Z",
  "last_used_at": null
}
~~~~

Valid: deepseek

~~~~
{
  "subject": "usr_01JAB2C3D4E5F6G7H8J9K0MNPQ",
  "owner": "codes",
  "provider": "deepseek",
  "base_url": null,
  "key_hint": "…MPLE",
  "models": {
    "chat": "deepseek-chat"
  },
  "budget_usd_per_day": 3,
  "spent_usd_today": 0.02,
  "created_at": "2026-10-30T00:00:00.000Z",
  "updated_at": "2026-10-30T00:00:00.000Z",
  "last_used_at": null
}
~~~~

Valid: link

~~~~
{
  "subject": "usr_01M4W5JBFEG3QG9ER8W1A2K0RX",
  "owner": "chat",
  "provider": "link",
  "machine": "dev_01M5YGM39VC2RRGDQPRD6D4SHD",
  "base_url": null,
  "models": {
    "chat": "llama3.1:8b"
  },
  "budget_usd_per_day": null,
  "spent_usd_today": 0,
  "created_at": "2026-10-27T13:00:00.000Z",
  "updated_at": "2026-10-27T13:00:00.000Z",
  "last_used_at": null
}
~~~~

Valid: stored

~~~~
{
  "subject": "usr_01JAB2C3D4E5F6G7H8J9K0MNPQ",
  "owner": "live",
  "provider": "openai",
  "base_url": "https://openrouter.ai/api/v1",
  "key_hint": "…MPLE",
  "models": {
    "chat": "gpt-4o-mini"
  },
  "budget_usd_per_day": 2,
  "spent_usd_today": 0.12,
  "created_at": "2026-09-28T00:00:00.000Z",
  "updated_at": "2026-09-28T00:00:00.000Z",
  "last_used_at": null
}
~~~~

Rejected: leaks-key

~~~~
{
  "subject": "usr_01JAB2C3D4E5F6G7H8J9K0MNPQ",
  "owner": "live",
  "provider": "openai",
  "api_key": "sk-EXAMPLE",
  "key_hint": "…MPLE",
  "created_at": "2026-09-28T00:00:00.000Z",
  "updated_at": "2026-09-28T00:00:00.000Z"
}
~~~~

Rejected: unknown-provider

~~~~
{
  "subject": "usr_01JAB2C3D4E5F6G7H8J9K0MNPQ",
  "owner": "codes",
  "provider": "groq",
  "key_hint": "…MPLE",
  "created_at": "2026-10-30T00:00:00.000Z",
  "updated_at": "2026-10-30T00:00:00.000Z"
}
~~~~

## Validate

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