Skip to content
Niu DocsNiu 牛元文档
Dashboard控制台

Create an encrypted Provider API-key configuration

Generated from the checked-in source. Do not edit this reference by hand.

POST /api/v1/vendors

Requires installation administration or an explicitly granted platform administrator. Each configuration has independent credentials and model bindings. Credentials are write-only and never returned.

Operation: createVendor.

Use the credential and permission scope described above. Each object below is an alternative; schemes within one object are required together.

JSON
[
{
"bearerAuth": []
}
]

Set NIU_ORIGIN to your installation origin (without /v1). Replace path, query and header placeholders with the required values. Query examples use curl 7.87 or newer to encode values with --url-query. Use the credential scope described above; a bearer token must have the authority required by this operation.

Shell
curl --fail-with-body -X POST "$NIU_ORIGIN/api/v1/vendors" \
-H "Authorization: Bearer $NIU_BEARER_TOKEN" \
-H 'Content-Type: application/json' \
--data @request.json

No path, query, or header parameters are declared.

Required.

JSON
{
"type": "object",
"additionalProperties": false,
"required": [
"name",
"adapter",
"api_base",
"api_key"
],
"properties": {
"name": {
"type": "string",
"minLength": 1,
"maxLength": 100
},
"adapter": {
"type": "string",
"enum": [
"openrouter",
"openai",
"anthropic",
"gemini",
"ark"
]
},
"api_base": {
"type": "string",
"format": "uri",
"maxLength": 2048,
"description": "HTTPS endpoint or HTTP loopback endpoint without URL credentials or query parameters."
},
"api_key": {
"type": "string",
"writeOnly": true,
"minLength": 1,
"maxLength": 8192
},
"enabled": {
"type": "boolean",
"default": true
},
"supplier_id": {
"type": "string",
"format": "uuid",
"description": "Existing Provider business to own this API-key configuration. Mutually exclusive with create_supplier=true; ownership and creation commit atomically."
},
"create_supplier": {
"type": "boolean",
"default": false,
"description": "Atomically create a Provider business with this name and its explicit configuration ownership link. Omission preserves legacy configuration-only creation."
}
}
}

Created vendor metadata wrapped in data. The credential is never returned.

Content type: application/json.

JSON
{
"type": "object",
"required": [
"data"
],
"properties": {
"data": {
"type": "object",
"additionalProperties": false,
"required": [
"id",
"name",
"adapter",
"api_base",
"enabled",
"revision",
"has_credential"
],
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"name": {
"type": "string"
},
"adapter": {
"type": "string",
"enum": [
"openrouter",
"openai",
"anthropic",
"gemini",
"ark"
]
},
"api_base": {
"type": "string",
"format": "uri"
},
"enabled": {
"type": "boolean"
},
"revision": {
"type": "integer",
"minimum": 1
},
"has_credential": {
"type": "boolean"
},
"owner_funded": {
"type": "boolean",
"readOnly": true,
"description": "Configuration-list metadata identifying a private credential owned by one account. Not accepted in configuration writes."
},
"supplier": {
"type": [
"object",
"null"
],
"description": "Provider ownership on configuration-list reads; credentials and commercial data are excluded.",
"required": [
"id",
"name"
],
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"name": {
"type": "string"
}
}
}
}
}
}
}

Invalid vendor configuration.

Invalid or expired administrative credential.

Platform administration permission required.

Vendor name already exists.

Storage or credential encryption unavailable.

Requires installation administration or an explicitly granted platform administrator. Each configuration has independent credentials and model bindings. Credentials are write-only and never returned.

Supported scope: implemented