Skip to main content

Test AI Provider Connection

Builds a temporary client from the submitted configuration and runs one short completion (the model is asked to say hello and name itself). Nothing is saved. Use it to check a key, model or endpoint before saving.

Reusing the stored key. An empty api_key probes with the key stored for the provider, so a model change can be checked without retyping it. With no stored key the request is refused with 79004. The stored key is only sent to the endpoint it is stored for (an empty base_url means the vendor's own): testing another base_url with it is refused with 10002 (domain 83). Send the key to test another endpoint.

Allowed targets. The endpoint must be public https, or an in-cluster host the environment lists; anything else is refused with 10001 (domain 83) before anything is sent.

A vendor failure is still a 200, with ok: false and the reason in error. On success, sample_answer carries the model's reply.

Platform owner only. The caller's node must be the platform root node; any other caller is refused with 403 / 10005.

Required permission: ai-provider:update

Request​

POST /v2/admin/ai-providers/test

Headers​

NameDescription
AuthorizationRequired. Bearer <access_token>
Content-TypeRequired. application/json

Body​

FieldTypeRequiredDescription
providerstringYesProvider key: claude or openai
modelstringYesModel to run the completion with
api_keystringNoAPI key to probe with. Empty means the stored key
base_urlstringNoAPI base URL. Empty means the vendor's own endpoint
timeoutintegerNoRequest timeout in seconds, 0 or greater

Example​

curl --request POST \
--url '{{baseUrl}}/v2/admin/ai-providers/test' \
--header 'Authorization: Bearer <access_token>' \
--header 'Content-Type: application/json' \
--data '{
"provider": "claude",
"api_key": "",
"base_url": "",
"model": "claude-sonnet-4-5",
"timeout": 30
}'

Response​

{
"ok": true,
"latency_ms": 1184,
"model": "claude-sonnet-4-5",
"sample_answer": "Hello! I am Claude, a model made by Anthropic."
}

Response Fields​

FieldTypeDescription
okbooleanWhether the completion succeeded
latency_msintegerDuration of the completion in milliseconds
modelstringThe model that was tested
sample_answerstringOnly when ok is true: the model's reply
errorstringOnly when ok is false: why the completion failed

Errors​

StatusCodeDescription
40010015Validation failed (provider or model missing, negative timeout) — see details
40079001Unsupported provider key (domain 79)
40079004api_key is empty and no key is stored for the provider (domain 79)
40010001Target refused: not https, does not resolve, or resolves to a private or metadata address (domain 83)
40010002The stored key would be sent to an endpoint other than the one it is stored for (domain 83)
40310005The caller is not the platform owner (domain 2)

See Errors for the error format and common codes.