Skip to main content

Create custom model

Create custom model. POST /api/openapi/v1/models/custom, scope admin.v1.models.manage.

  • Scope: admin.v1.models.manage
  • Permission: Manage Models
  • Action: manage
  • Endpoint: POST/api/openapi/v1/models/custom
Use Authorization: Bearer \<API_KEY\>. The application must have subject_scope={"mode":"all"}; restricted scopes return 403. Scopes are independently granted. Do not cache responses. Model configuration covers BYOK custom models and system-model listing. Creation reuses UI test-and-save: probe first, persist nothing on failure, and save without activating on success. models/connection-tests is an independent preflight that persists neither model nor credentials. BYOK feature and management gates, endpoint restrictions and credential handling remain unchanged. Lists remain paginated. Creation requires Idempotency-Key. No update, deletion, activation or credential-rotation operation is added.

Common request headers

Apply the “Authentication and headers” section in “Configure the QwenWork console through APIs”: Authorization is required and X-Request-Id is optional. See this page for the required scope. Whether Idempotency-Key applies and is required is specified in this page’s request parameters; a tracing identifier does not replace an idempotency key.

Request parameters

Request body: required; Content-Type: application/json.
NameLocationTypeRequiredDescriptionExample
Idempotency-KeyheaderstringYesIdempotency-Key; maxLength=255-
api_keybodystring · password | nullNoapi key; format="password", maxLength=8192-
descriptionbodystringNodescription; maxLength=2000-
description_i18nbodyobjectNodescription i18n-
display_namebodystringYesdisplay name; maxLength=255-
display_name_i18nbodyobjectNoDisplay names by locale-
endpoint_urlbodystring · uriYesendpoint url; format="uri", maxLength=2048-
is_reasoningbodybooleanYesis reasoning-
is_vlbodybooleanYesis vl-
max_context_window_tokensbodyinteger · int64Yesmax context window tokens; format="int64", minimum=1-
pass_third_party_user_idbodybooleanYespass third party user id-
protocol_profilebodystringYesprotocol profile; enum=["openai_chat_completions_v1"] Values: "openai_chat_completions_v1"-
provider_adapterbodystringYesprovider adapter; enum=["openai_compatible"] Values: "openai_compatible"-
upstream_modelbodystringYesupstream model; maxLength=255-

Response statuses

HTTP statusTriggerResponse structureClient action
201Request succeededSee “Response” on this pageRead the response.
defaultOther authentication, authorization, validation or dependency errorsSee “General error” in “Configure the QwenWork console through APIs”Handle the status and code; verify the result and idempotency requirements before retrying writes.

Response

Content-Type: application/json
NameTypeRequiredDescriptionExample
api_key_configuredbooleanYesapi key configured-
created_atstring · date-timeYescreated at; format="date-time"-
created_byobjectYesCreator ID-
credential_configuredbooleanYescredential configured-
credential_fingerprintstringNocredential fingerprint-
credential_versioninteger · int64Nocredential version; format="int64"-
descriptionstringNodescription-
description_i18nobjectNodescription i18n-
display_namestringYesdisplay name-
display_name_i18nobjectNoDisplay names by locale-
endpoint_urlstringYesendpoint url-
idstring · uuidYesid; format="uuid"-
is_reasoningbooleanYesis reasoning-
is_vlbooleanYesis vl-
last_test_codestringNolast test code-
last_test_resultstringNolast test result; enum=["success", "failed"] Values: "failed", "success"-
last_tested_atstring · date-timeNolast tested at; format="date-time"-
lifecyclestringYeslifecycle; enum=["draft", "test", "active", "disabled"] Values: "active", "disabled", "draft", "test"-
max_context_window_tokensinteger · int64Yesmax context window tokens; format="int64", minimum=1-
model_keystringYesmodel key-
pass_third_party_user_idbooleanYespass third party user id-
protocol_profilestringYesprotocol profile; enum=["openai_chat_completions_v1"] Values: "openai_chat_completions_v1"-
provider_adapterstringYesprovider adapter; enum=["openai_compatible"] Values: "openai_compatible"-
row_versioninteger · int64Yesrow version; format="int64"-
target_versioninteger · int64Yestarget version; format="int64"-
updated_atstring · date-timeYesupdated at; format="date-time"-
updated_byobjectYesUpdater ID-
upstream_modelstringYesupstream model-

created_by

FieldTypeRequiredDescription
emailstring · emailNoemail; format="email"
namestringNoName
user_idstring · uuidYesuser id; format="uuid"

updated_by

FieldTypeRequiredDescription
emailstring · emailNoemail; format="email"
namestringNoName
user_idstring · uuidYesuser id; format="uuid"

Runtime limits and contract notes

A failed connection probe returns HTTP 422 / custom_model_connection_test_failed with required string test_code at the error root, containing a sanitized failure classification. Other validation errors do not include this field; the model is not saved.

Errors and retries

Existing UI error codes and validation are preserved. 401/403 indicate authentication or authorization failure; 409 requires rereading before retry; 413 indicates an oversized request; 400/422 indicate invalid input; 503 indicates an unavailable dependency. The response and machine contract are authoritative. Retry idempotent creates with the same Idempotency-Key and payload.