Connect an AI provider key
SDK platic.aiProviders.connect()
Store and test a provider key in one call. If a key is already connected, replace it.
Example
curl -X PUT https://api.platic.ai/v1/ai-providers/openai \
-H "Authorization: Bearer $PLATIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "value": "your-openai-key" }' await platic.aiProviders.connect("openai", { value: "your-openai-key" }); Path parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
provider | string | openai, google, anthropic, or xai | ✓ |
Request body
| Field | Type | Description | Required |
|---|---|---|---|
value | string | The provider's key, up to 4,096 characters | ✓ |
fallback | string | What agents do while the key does not work: platform or none. Without it, the provider keeps the one it had, or platform if it is new. See the fallback | — |
{
"value": "sk-proj-example",
"fallback": "platform"
} Response
200 OK with the provider after the test, in the shape of list AI providers. It never includes the key.
{
"status": "success",
"message": "Key connected and verified",
"data": {
"provider": "openai",
"name": "OpenAI",
"status": "connected",
"health": "ok",
"fallback": "platform",
"lastVerifiedAt": "2026-11-13T16:20:00.000Z",
"lastError": null,
"secretName": "OpenAI key",
"models": [
{ "id": "gpt-6.1-sol", "name": "GPT-6.1 Sol", "status": "available", "code": null, "ownKeyOnly": false },
{ "id": "gpt-6.1-terra", "name": "GPT-6.1 Terra", "status": "available", "code": null, "ownKeyOnly": false },
{ "id": "gpt-6-luna", "name": "GPT-6 Luna", "status": "unavailable", "code": "MODEL_OR_DEPLOYMENT_NOT_FOUND", "ownKeyOnly": false }
]
}
} If the key does not work, the response is also 200: status is invalid, lastError says why, and message is Key saved, but it does not work: see lastError.
Errors
| Status | details.code | When it happens |
|---|---|---|
400 | INVALID_PROVIDER | {provider} is not one of the four |
400 | INVALID_REQUEST | value is missing, empty, or over 4,096 characters, fallback is neither platform nor none, or the body has an unknown field. details.issues says which, without repeating the key |
403 | FORBIDDEN | The person behind the token cannot manage and use secrets |
429 | VERIFICATION_RATE_LIMITED | There were already 10 tests of that provider in the last hour |
503 | VERIFICATION_FAILED | The key could not be tested with the provider. Get the provider before retrying |
Warning
Do not log or display the key after sending it. If an AI assistant connects it for you, the key goes through that conversation: to avoid it, connect it in Platica, under Settings → Models (BYOK).
Notes
- The test spends a few tokens from your provider account and can take a while: wait for the response for up to 200 seconds.
- The key is stored as a workspace secret named, for example,
OpenAI key. Replacing it stores the new one, removes the authorization of the previous one, and deletes it from Secrets. If you renamed the previous one or another integration uses it, it stays in Secrets. - To test it again without sending it, use test an AI provider key.